7

Thunar does not have the option of a prompt asking for confirmation when moving files to trash (this is, when pressing the Delete key). I want to add one.

The only way I can think of doing this by creating a new "Custom action", which accepts scripts and binaries (in the "Command" option, below):

enter image description here

Maybe I can create a script file that executes the delete after a confirmatory prompt. Once that is done, the rest is easy: just link that action to the Delete key.

But the truth is I have no idea how to start. I actually don't know if this is the best approach. Maybe there is a better one?

1 Answers1

10

You can put whatever you want for the name and description, but here's the command part:

zenity --question --text="Are you sure you want to delete %F?" && rm -rf %F

It shows a dialog asking the user whether they want to delete the file(s) and if so, it deletes it. Also, if you just wanted to move the files to the trash, since Thunar already asks when you use Shift+Delete, then use this:

zenity --question --text="Are you sure you want to move %F to the trash?" && gio trash %F

Lastly, be sure to click on the "Appearance Conditions" tab and check all the file types so that the action won't just appear on text files

enter image description here

To enable the keyboard shortcut for this action, proceed as explained here. Basically, in the file ~/.config/Thunar/accels.scm, edit the corresponding custom action, so that it looks like this:

(gtk_accel_path "<Actions>/ThunarActions/uca-action-1484038296058938-2" "Delete")
Evan Chen
  • 847
  • 6
  • 11
  • Update: gio trash instead of gvfs-trash – tjbrn Feb 08 '20 at 22:36
  • Excuse me, but has this actually ever worked for anybody? Because firstly, the file accels.scm gets overwritten automatically with the default content on each system start-up. Secondly, you may not choose the 'Delete' key for your custom action as it is sewn deeply in the Thunar source code to invoke 'moving to the trash' (bypassing any confirmation dialog). When I try to set the keyboard shortcut to be the 'Delete' key, it says, 'This keyboard shortcut is already in use: «trash-delete»'. My version of Thunar is 4.16.8. – bighugedev Nov 19 '24 at 02:58