XFCE: Enable trash outside of home

Step-by-Step descriptions of how to do things.
Post Reply
User avatar
peter_b
Chatterbox
Posts: 381
Joined: Tue Nov 12, 2013 2:05 am

XFCE: Enable trash outside of home

Post by peter_b »

I usually have more than one drive in my computers.
Every now and then I run into the weird behavior that when I want to remove but not delete (=send to trash/recycle bin) files or folders, it doesn't work:
Error message when trash folder is not properly set up or not existing.
Error message when trash folder is not properly set up or not existing.
thunar-trash_not_found.png (14.61 KiB) Viewed 8618 times
I'm forced to either let it be or remove it completely.
This short HowTo is about how to enable local trash folders on different harddisks.

A short peek into The FreeDesktop.org Trash specification (v1.0, January 2014) revealed that this should be possible. Excellent!
If a certain folder exists on mounted drives, it will be used as preferred trash folder for that medium (to avoid having to copy/move files to the trash folder in the user's home directory).

A trash folder per drive.
On each disk where you want to be able to trash stuff, you have 2 options for a trash folder:
  • .Trash/$UID
  • .Trash-$UID
Where "$UID" is the UID (user ID) of the user who's allowed to use that trash.
I prefer the common .Trash folder with subdirectories per $UID.

1) Create ".Trash"

As root:

Code: Select all

$ mkdir $NEW_DRIVE/.Trash
$ chmod 777 $NEW_DRIVE/.Trash
$ chmod +t $NEW_DRIVE/.Trash
Where "$NEW_DRIVE" is the mount point of the disk where you want to trash files. "chmod +t" sets the sticky bit (which is mentioned mandatory in the specs).

btw: (X)ubuntu usually creates ".Trash-$UID" folders, resulting in ".Trash-1000" or ".Trash-1001", etc folders on external harddisks.
The FreeDesktop.org Trash specification mentions that as 2nd option:
(2) If an $topdir/.Trash directory is absent, an $topdir/.Trash-$uid directory is to be used as the user's trash directory for this device/partition. $uid is the user's numeric identifier.

2) Manually trash a file using "gio"
I expected Thunar to create the $UID subfolder once I have a .Trash folder in root. It doesn't.

Code: Select all

$ gio trash delme.txt
This sends the file "delme.txt" to a trash: If the new .Trash folder was created correctly, gio now creates a subfolder with your user's $UID and puts your trashed files there.

From now on, Thunar also uses the new trash option.

Voila! :D


Not helpful here, but fun to read: Blog about trash management in XFCE (2004)
Post Reply