I generally prefer XFCE desktop environment of Xubuntu, but I found its files right-click context menu too humble (no option to compress/decompress files for example, and I'd like some my very special actions there too).
How can I customize it?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
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.
thunar, if you go to edit > configure custom actions, you will see the menu as below (minus my custom actions of course):
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
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.)
Now, only when you right click a text file, will the
espeak option come up, as in the screenshot below.
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:
txt: under 'Appearance conditions' tab, check 'Text files', and then add
*.txtfor 'File pattern'.
png: check 'Image files', and
*.pngfor 'File pattern'.
flv: 'Video files', and
Thunar plugins cover a limited area of options.
The main way to add new context menu options is (as Mik said) done by going to 'Edit/Configure custom actions' - and clicking "+" to add.