Trash management

From ArchWiki
Jump to navigation Jump to search

To prevent accidental deletion of files, you can use a trash can. To ensure compatibility between multiple applications, you can use software (CLI, GUI or Library) that follow the FreeDesktop.org's Trash specification.

Note: Some applications can use a trash can per filesystem (see the specification)
Warning: When deleting files on another filesystem, usage of a trash can induce some latency because the files will be transferred between filesystems. In this case, you might want to use a implementation that create a trash folder per filesystem (See Trash directories in the specification).

Trash creation

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Add other utilities (Discuss in Talk:Trash management#)
  • glib2 provides a gio trash [FILE1] [FILE2] ... command that allows to move files into the trash, while gio trash --empty empties the trash
  • trash-cli — A command-line interface implementing FreeDesktop.org's Trash specification.
https://github.com/andreafrancia/trash-cli || trash-cli
  • bashtrash — Freedesktop-complient trashcan implemented in bash script
https://github.com/robrwo/bashtrash/blob/master/trash || bashtrashAUR
  • trashman — A Python trash manager
https://github.com/Kwpolska/trashman || trashmanAUR
  • rmtrash — trash-put made compatible to GNUs rm and rmdir
https://github.com/PhrozenByte/rmtrash || rmtrashAUR

Trash space usage management

To prevent the trash can from using to much space, you can empty it yourself, or have a pruning policy

Software list

autotrash (not in the AUR)

Criteria

Tango-view-fullscreen.pngThis article or section needs expansion.Tango-view-fullscreen.png

Reason: Add table with a list of criteria (Discuss in Talk:Trash management#)
  • make sure to have at least x MB of free space
  • delete files older than x days
  • only empty if you have less than x MB of free space (useful in combination of previous criteria)
  • maximum trash can size
  • file size
  • file type
  • original path

Automation

To automate emptying the trash can, you can use cron, systemd/Timers, or inotify (using inotify, only new deletion would trigger the trash can automation)