A small Linux utility that automatically cleans the trash based on item age and/or total size.
- Linux
- systemd (required for the
installcommand) - Rust and Cargo (only required when building from source)
With cargo
cargo build --releaseWith nix
nix buildThis tool will be packaged for the most popular Linux distributions and uploaded to crates.io from a certain star rating.
Run the following command to display the available commands:
trashguard helpOutput:
A program that allows you to regularly empty the trash
Usage: trashguard [OPTIONS] <COMMAND>
Commands:
run Run the trash cleanup
install Install a systemd service to run the cleanup every day
uninstall Uninstall the systemd service
help Print this message or the help of the given subcommand(s)
Options:
-d, --debug Enables information messages
-h, --help Print help
-V, --version Print versionRun the following command to view the available cleanup settings:
trashguard run helpOutput:
Run the trash cleanup
Usage: trashguard run [OPTIONS]
Options:
-d, --debug Enables information messages
-m, --mode <MODE> Element deletion mode [default: both] [possible values: date, size, both]
--max-days <MAX_DAYS> The maximum number of days an item remains in the trash [default: 14]
--max-size <MAX_SIZE> The amount of data that the trash should not exceed [default: "10.0 GiB"]
-h, --help Print helpThe following command will delete all items from the trash that have been there for more than 7 days.
trashguard run --mode date --max-days 7 --debugThe program retrieves various information about all the items present in the Recycle Bin. Then it sorts all the items from newest to oldest. Afterwards, it goes through all the elements until the cleaning criterion is no longer respected. Once the criterion is no longer met, all remaining elements in the list are permanently deleted. Note: with both mode, the elements are deleted as soon as one of the two criteria is no longer respected.
By default, trashguard removes items that:
- are older than 14 days, and/or
- cause the trash to exceed 10 GiB.
The cleanup can be run manually with trashguard run, or scheduled daily using the systemd service installed with trashguard install.
Enter the development environment:
nix develop