XFCE: Enable trash outside of home

Step-by-Step descriptions of how to do things.

XFCE: Enable trash outside of home

Postby peter_b » Sat Apr 25, 2020 2:33 am

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:
thunar-trash_not_found.png
Error message when trash folder is not properly set up or not existing.
thunar-trash_not_found.png (14.61 KiB) Viewed 515 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)
  • 0

User avatar
peter_b
Chatterbox
 
Posts: 305
Joined: Tue Nov 12, 2013 2:05 am
Reputation: 3

Return to HowTo's

Who is online

Users browsing this forum: No registered users and 1 guest

Who is online over last 24 hours

Users browsed this forum in the last 24 hours: No registered users and 19 guests

cron
Reputation System ©'