How to customize files context menu in Xubuntu XFCE Thunar file manager?

The best way to do this is to use the excellent Thunar custom actions feature (now installed as default with Thunar), and as there are no detailed tutorials here I thought it was worth adding one. When a custom action is created it is added to the context menu, as I will show in my discussion below. However, you can tailor when it appears in the context menu and, for example, make sure that your custom action only appears when image files are right-clicked on.

In thunar, if you go to edit > configure custom actions, you will see the menu as below (minus my custom actions of course):

enter image description here

You can either create a new custom action (see the discussion below) or edit an existing one. There are many useful examples at the Xfce site and at the Ubuntu wiki, so there is no need to go through them all here, but we will just discuss a few examples to display the usefulness of this feature in Thunar.

You would create a new custom action by clicking the add button (shown in the first screenshot). Then you would put the below command, for example, in the command box (like I have done for a different example in screenshot 2):

zenity --question;if [ $? = 0 ];then srm -rvf %F;fi

and then make sure that the correct file types were selected in the Appearance Conditions menu (as I have done for a different example in screenshot 3).

The command above uses srm (which is in the package called secure-delete), and one should be very careful in using it on files. Hence, the GNOME dialog program, Zenity, is often used if confirmation is needed for the actions (like it was used here) so that files are not removed accidentally.

However, to use a safer example than srm, we can use the example of espeak, so that we can get espeak to read any text file to us. We would create a new custom action and then we would put in the command box (as in screenshot 2)

espeak -s 135 -f %f

Espeak needs to be installed if it isn't already (with sudo apt-get install espeak); the -s option I have used just slows down the speed of the speech a bit; you can specify other parameters as well like different voices, but the -f switch must always go before %f as it shows espeak the text input file to use.

(You can add an icon if you wish (see the screenshot below), so that the context menu looks more interesting.)

enter image description hereenter image description here

Now, only when you right click a text file, will the espeak option come up, as in the screenshot below.

enter image description here

There is so much more that can be done with custom actions, but this was just an introduction to the basic ways of creating your own context menu item. There is a lot more information at the Xfce wiki and a lot of useful examples, and there are also some excellent examples of custom actions in this forum.


To restrict a command to a certain type of files:

  • only to txt: under 'Appearance conditions' tab, check 'Text files', and then add *.txt for 'File pattern'.
  • only for png: check 'Image files', and *.png for 'File pattern'.
  • only for flv: 'Video files', and *.flv.
  • for other files, like pdf: check 'Other files', and add *.pdf. etc.

Look at these links,

  • Thunar Plugins
  • Installing thunar-archive-plugin