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 setup 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.
This section provides a step-by-step introduction to the Custom Actions plugin, demonstrating how to add a Print File action, which uses xfprint to print text files. 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.
On the first page, enter Print File
as name and Print the selected using xfprint
as description. Enter xfprint4 %f
as command (the %f
will be replaced with the path to the selected file, as explained in the dialog), and select an icon for the icon (in the screenshot the xfprint.svg
icon was used). NB: Thunar seems to do the sensible thing when passing file/folder names with spaces in them, so don't worry excessively about putting single or double quotes around the “%” placeholder.
Now, continue with the second page (the Appearance Conditions page).
We want to create an action that is only applicable to text files, so select the Text Files 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 text files.
That's all. Click OK to close the Create Action dialog. The new action, labeled Print File will appear in the Custom Actions list.
Now close the Custom Actions dialog, select a text file in Thunar and open the context menu (right-click on the file icon). The newly created Print File action will appear in the context menu, as shown in the screenshot below.
You can use the thunar-dev mailinglist to get in touch with the developers, if you have questions about this short tutorial or custom actions in general.
Here are a few useful examples of custom actions. Feel free to extend this list.
gnome-search-tool –path=%f
Note: For this action, you'll need to have gnome-search-tool
installed, which is part of the gnome-utils
package. This program also has a lot of other nice command-line options which you could use to create even more specialized actions.
catfish --fileman=thunar --path=%f
Note: For this action, you'll need to have catfish
installed, which is part of the catfish
package.
catfish --fileman=thunar --path=%f%d
Note: For this action, you'll need to have catfish
installed, which is part of the catfish
package.
tar xjf %n
unzip %f
tar czvf %n.tar.gz %n
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.
xmms %F
xmms -e %F
Hint: Works exactly the same with Audacious.
k3b --cdimage %f
gqview %f
Note: This tip also works just as well with GThumb
convert %f -quality 75 %f.jpg
Hint: `basename %f .png`.jpg
(be careful–those are backticks) will strip the old .png extension off of the original filename.
for file in %F; do tempfile=$(mktemp); (jpegtran -copy all -rotate 90 $file > $tempfile); mv -f $tempfile $file; rm -f $tempfile; done
Note: jpegtran is available as part of the libjpeg or libjpeg-progs packages of most distributions. Unlike using “convert”, the complicated loop structure is necessary with “jpegtran”: “jpegtran -rotate 90 -outfile %F %F” will produce a 0kb file.
terminal --default-working-directory=%d
Note: You might need to type xfce4-terminal
instead of just terminal
for some distributions.
gksu “xfce4-terminal –default-working-directory=%f”
Note: You should rewrite the command with normal straight quotes.
gksu thunar %f
gksu put-your-favourite-text-editor-here %f
Note: You'll need to replace put-your-favourite-text-editor-here with your favourite text editor (e.g. mousepad or geany).
ln -s %f “%n (symlink)”
For fans of the Windows “SendTo Extensions” power toy. This tip requires the xclip
program, which you may need to install using your distribution's package manager.
echo -n %f | xclip -i
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/image-path -s %f
baobab %d
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.
terminal -x nano %f
Since nano isn't a GUI app, you must start it in a terminal window.
meld %F
Note: You will need meld
package.
Note: You will need unoconv
package for all following actions.
unoconv -f odt %F
unoconv -f pdf %F
You can go on, try man unoconv
for details.
periscope -l en %F && zenity –info –title “Done” –text “Subtitles downloaded successfully” || zenity –error –title “Error” –text “Subtitles not downloaded successfully”
Note: You will need python-periscope
package. Get it here. You'll also neeed zenity
package. This command will try to get the English subtitles, change -l en
to something else (fr
, de
, pt-br
, …). You should rewrite the command with normal straight quotes.
subrnm %F
Note: You will need subrnm
script. Get it here. You'll also neeed zenity
package.
Note: You will need the script here (which I name thunar-resize-sendto and place in /usr/local/bin), “zenity”, and “imagemagick” packages. I used the xfce-newmail icon. Use the following command line:
/usr/local/bin/thunar-resize-sendto %F
Not sure why this isn't part of Thunar plugins, since it's pretty sweet. Tested on Xubuntu Lucid.
NOTE!: This uses /tmp/thunar-pics0 & /tmp/thunar-pics1 as temp directories, and will completely remove anything in these directories. I doubt there's a conflict, but you've been warned. You can see the list of files it creates below in /tmp.
#!/bin/bash #input to this is a list of files to send. # depends on thunar, ImageMagick and Zenity TMP=/tmp/thunar-pics LOG=/tmp/thunar-resize-sendto.log MARKER=/tmp/thunar-resize-sendto.marker SENDTO="/usr/lib/thunar/thunar-sendto-email" SIZES="320x200 640x480 800x600 1024x640" DISCMD="zenity --list --text=\"Select Size\" --checklist --column=Select --column=New --hide-header --print-column=ALL" # Find unused tmp dir if [ -e $MARKER ]; then CUR=$(cat $MARKER) else CUR=1 fi if [ 1 == $CUR ]; then CUR=0 else CUR=1 fi echo "$CUR" >$MARKER TEMP="${TMP}$CUR" mkdir -p $TEMP rm -rf $TEMP/* for s in $SIZES; do if [ -z $COLS ]; then COLS="$s " else COLS="$COLS 0 $s" fi done SIZE=$($DISCMD $COLS) echo "CUR=$CUR SIZE=$SIZE" >$LOG for f in "$@"; do n=$(basename "$f") echo "item '$f'->$TEMP/$n" >>$LOG convert $f -resize $SIZE "$TEMP/$n" FILES="$FILES $TEMP/$n" done $SENDTO $FILES