5

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?

9

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?" && gvfs-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")
  • Update: gio trash instead of gvfs-trash – tjbrn Feb 8 at 22:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy