Thunar - Custom Actions

Thunar allows users to add custom actions to the file and folder context menus (by the use of the thunar-uca plugin, part of the Thunar distribution, in the plugins/ subdirectory). You can set up new actions in the Custom Actions dialog, available via the Configure custom actions... item in the Edit menu.

This page serves as an introduction to the Custom Actions plugin, and includes a list of useful examples.


Adding a Custom Action

This section provides a step-by-step introduction to the Custom Actions plugin, demonstrating how to add a simple action. We start by opening the Custom Actions dialog as explained above. In the dialog, click on the first button in the list of buttons (the one labeled with the +). The Create Action dialog will appear, as shown in the screenshot below.

Create Action Dialog

On the first page, enter Create symlink in Name: Enter ln -Ts %f %n“ (link)” for the Command: (the %f will be replaced with the path to the selected file, as explained in the dialog), and select an icon by clicking Icon: (in the screenshot emblem-symbolic-link was used).

Optionally, you can specify a Submenu:, in order to group multiple custom actions into the same menu.

Never quote field codes, unless you know why [particularly true if their expansion contains quotes, but not only]

Always quote shell variable expansions, unless you know why [classical shell programming advice, but it might be useful to recall here]

When a field code appears in quotes, you can generally extract it and concatenate:

  cmd "foo %f bar" (wrong) ->; cmd "foo "%f" bar" (correct)

Or you can put its content in a shell variable and use this variable instead:

  cmd "foo %f bar" (wrong) ->; f=%f; cmd "foo $f bar" (correct)

In case of multiple arguments, you can safely use a for loop in that way:

  for f in %F; do cmd "foo $f bar"; done

Now, continue with the second page (the Appearance Conditions page).

We want to create an action that is only applicable to folders, so select the Folders options and unselect the options for the other file types. Next you can specify a File Pattern to display the action only for text files that match a certain pattern. In the example, we set the file pattern to * (which matches all filenames) to indicate that the action should be displayed for all folders.

That's all. Click OK to close the Create Action dialog. The new action, labeled Search with Catfish will appear in the Custom Actions list.

Now close the Custom Actions dialog, select a folder in Thunar and open the context menu (right-click on the file icon). The newly created Search with Catfish action will appear in the context menu, as shown in the screenshot below.

Custom Actions Dialog

Back to Top


Using mnemonics to open Custom Actions

When you create a Thunar Custom Action you can set the name with an underscore “_” before a letter to use it as mnemonic. When you right click in a Thunar view, you can type the letter to access your custom action.


Examples

Here are a few useful examples of custom actions. Feel free to extend this list.

Search files with catfish

Note: For this action, you'll need to have catfish installed, which is part of the catfish package.


Work with archives (tar, gzip, etc)

Hint: You may prefer the Thunar Archive Plugin, which does pretty much the same thing with less manual setup required on your part. It's either included with your distribution (in the case of Xubuntu), or available as a separate package (thunar-archive-plugin in Debian Etch). You might also need the xarchiver or “squeeze” package for things to work quite right.


Play/Enqueue music files

Hint: Works exactly the same with Audacious.


Convert PNGs to JPEGs

Hint: "$(basename %f .png).jpg" will strip the old .png extension off of the original filename.


Rotate JPEGs

Note: exiftran is available for most distributions.


Open terminal here

Command 1 will open a terminal on all selected folder.

Command 2 in addition will open a terminal on the current directory, when executed on a non-folder files (or multiple)


Open root terminal here

Note: Use either pkexec or gksu, depending on what is available for your distro.

Note: You should rewrite the command with normal straight quotes.


Open thunar as root here

Note: Some distributions no longer include gksu. Use pkexec or the admin interface instead.


Edit file as root

Note: You'll need to replace put-your-favourite-text-editor-here with your favourite text editor (e.g. mousepad or geany). Also, see previous note about gksu.




View disk usage of the current directory

Note: The idea is to get a visual picture of the current directory and any subdirectories. You could also use fsview or filelight, but the visuals are crisper in baobab.


Open file in terminal text editor


Compare selected files/directories

Note: You will need the meld package.


Change OpenDocument-supported formats

Note: You will need unoconv package for all following actions.

You can go on, try man unoconv for details.


Download video subtitles

Note: You will need to follow the instructions on OpenSubtitlesDownload which requires python and zenity (check the link for a complete list of requirements). You can tweak the behavior of the python script simply by editing with a text editor, the code is all commented, so it is very easy to understand.


Rename subtitles easily

Note: You will need subrnm script. Get it here. You'll also need zenity package.


Move files into a new folder

Note: You'll will need the zenity package.


Create Shared Thumbnails

Note: Required to download this script and store it locally. Requires python3 and realpath.


Use 'bulk rename' on a single file


Trust multiple desktop files at once

Back To Top


Back to Thunar documentation page