Skip to content

About

A small Linux utility that automatically cleans the trash based on item age and/or total size.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

trashguard

A small Linux utility that automatically cleans the trash based on item age and/or total size.

Prerequisites

  • Linux
  • systemd (required for the install command)
  • Rust and Cargo (only required when building from source)

Building

With cargo

cargo build --release

With nix

nix build

Installation

This tool will be packaged for the most popular Linux distributions and uploaded to crates.io from a certain star rating.

Usage

Run the following command to display the available commands:

trashguard help

Output:

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 version

Run the following command to view the available cleanup settings:

trashguard run help

Output:

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 help

Example

The 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 --debug

How it works

The 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.

Development

Enter the development environment:

nix develop

About

A small Linux utility that automatically cleans the trash based on item age and/or total size.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages