Rubbish Bin - change from duration to space used?

Is it possible to configure the Rubbish to delete the oldest files when it reaches a specified size?

It looks like this article proposes autotrash which seems to be is a snap package only. I cannot find it in the default repositories on Zorin OS nor Debian. For those already using snaps this may not be an issue, but it would be wasteful to have to install the entire snapd package just for this one utility.

As an aside, deleting the Trash based on the size seems something to approach carefully. Considering that the point of having a Trash directory is to have a safety net against accidental deletion of files, you wouldn't want to accidentally delete a particularly large file that triggers the clean up, thereby getting rid of the ability to restore other files that might have been there already.

I realize that everybody's use case is different of course but I think this is important to mention nonetheless. For most uses, the available time settings are a good balance between storage space — quite cheap these days — and convenience.

To address the actual question of this topic, I wrote a little script to check for a specific size and empty the trash accordingly. It can be scheduled to run as a cron job once a day for example. Use at your own risk :smiley:

#!/bin/bash

TRASH_SIZE_IN_BYTES="$(du -bs "$HOME"/.local/share/Trash/files \
    | awk '{ print $1 }')"

# 2GiB
THRESHOLD_IN_BYTES=$(( 1024 * 1024 * 1024 * 2))

if [[ $TRASH_SIZE_IN_BYTES -ge $THRESHOLD_IN_BYTES ]]; then
    rm -rf "$HOME"/.local/share/Trash/{files,info}/*
fi
3 Likes

Interesting, thanks. I didn't think of using BASH. I'll have a play, at my own risk :slight_smile:

btw, i did a test in a VM - Zorin went all the way to less than 1 GB in / before warning. Not ideal!

image

The practicality of KDE Plasma:

image

As beautiful as Gnome is, it is SO limiting.

1 Like