Xfce Wiki

Sub domains
 

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
xfce:thunar:custom-actions [2012/12/04 11:13] – created nickxfce:thunar:custom-actions [2019/11/22 02:55] – added bottom of page navigation kevinbowen
Line 1: Line 1:
-====== Custom actions ======+====== 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 setup new actions in the {gui>Custom Actions} dialog, available via the {gui>Configure custom actions...} item in the {gui>Edit} menu.+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 {gui>Custom Actions} dialog, available via the {gui>Configure custom actions...} item in the {gui>Edit} menu.
  
 This page serves as an introduction to the **Custom Actions** plugin, and includes a list of useful examples. This page serves as an introduction to the **Custom Actions** plugin, and includes a list of useful examples.
  
-===== Adding a custom action =====+===== Adding a Custom Action =====
  
 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. 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.+<figure "Create Action Dialog"> 
 +{{:xfce:thunar:uca-create.png?nolink&|}} 
 +</figure> 
 + 
 +On the first page, enter ''Search with Catfish'' in {gui>Name:and ''search'' in {gui>Description:Enter ''catfish %f'' for the {gui>Command:(the ''%f'' will be replaced with the path to the selected file, as explained in the dialog), and select an icon by clicking {gui>Icon:(in the screenshot the ''system-search.svg'' icon was used). <note>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.</note>
  
 Now, continue with the second page (the {gui>Appearance Conditions} page). Now, continue with the second page (the {gui>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.+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 **Print File** will appear in the **Custom Actions** list.+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 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.+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.
  
-{{ documentation:thunar-custom-actions-3.png }}+<figure "Custom Actions Dialog"> 
 +{{:xfce:thunar:uca-list.png}} 
 +</figure>
  
-You can use the [[http://thunar.xfce.org/pwiki/start#mailinglist|thunar-dev mailinglist]] to get in touch with the developersif you have questions about this short tutorial or custom actions in general.+===== Use mnemonics to open Thunar 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 ===== ===== Examples =====
Line 27: Line 35:
 Here are a few useful examples of custom actions. Feel free to extend this list. Here are a few useful examples of custom actions. Feel free to extend this list.
  
-==== Finding files in the current folder ====+==== Finding files in the current folder with gnome-search-tool ====
     * Name: **Search...**     * Name: **Search...**
     * Command: ''gnome-search-tool --path=%f''     * Command: ''gnome-search-tool --path=%f''
Line 36: Line 44:
  
  
- +==== Finding files inside the current/selected folder with catfish ====
- +
- +
- +
-==== Finding files in the current folder with catfish ==== +
-    * Name: **Search files...** +
-    * Command: ''%%catfish --fileman=thunar --path=%f%%'' +
-    * File pattern: * +
-    * Appears if selection contains: Directories +
- +
-**Note:** For this action, you'll need to have ''catfish'' installed, which is part of the ''catfish'' package. +
- +
- +
- +
- +
- +
- +
-==== Finding files inside the selected folder with catfish ====+
     * Name: **Search files inside...**     * Name: **Search files inside...**
-    * Command: ''%%catfish --fileman=thunar --path=%f%d%%''+    * Command: ''catfish %f''
     * File pattern: *     * File pattern: *
     * Appears if selection contains: Directories     * Appears if selection contains: Directories
Line 84: Line 75:
     * File pattern: *     * File pattern: *
     * Appears if selection contains: Directories, Audio Files     * Appears if selection contains: Directories, Audio Files
- 
     * Name: **Enqueue in XMMS**     * Name: **Enqueue in XMMS**
     * Command: ''xmms -e %F''     * Command: ''xmms -e %F''
Line 113: Line 103:
  
 **Hint:** ''`basename %f .png`.jpg'' (be careful--those are //back//ticks) will strip the old .png extension off of the original filename. **Hint:** ''`basename %f .png`.jpg'' (be careful--those are //back//ticks) will strip the old .png extension off of the original filename.
- 
- 
  
 ==== Losslessly Rotating JPEGs ==== ==== Losslessly Rotating JPEGs ====
Line 122: Line 110:
     * Appears if selection contains: JPEG Image Files     * Appears if selection contains: JPEG Image Files
 **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. **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.
 +
 +[[https://thelinuxchronicles.blogspot.com/2012/06/thunar-custom-actions-resize-and-rotate.html|Here an example]] how rotation can be scripted with "convert".
  
 ==== Opening a terminal ==== ==== Opening a terminal ====
Line 145: Line 135:
     * Appears if selection contains: Directories     * Appears if selection contains: Directories
  
 +**Note:** Some distributions no longer include ''gksu''. Use ''pkexec'' instead.
 ==== Editing as root ==== ==== Editing as root ====
     * Name: **Edit as root**     * Name: **Edit as root**
Line 151: Line 142:
     * Appears if selection contains: Text files     * Appears if selection contains: Text files
  
-**Note:** You'll need to replace put-your-favourite-text-editor-here with your favourite text editor (e.g. mousepad or geany).+**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''.
  
 ==== Creating a symbolic link ==== ==== Creating a symbolic link ====
Line 166: Line 157:
     * File pattern: *     * File pattern: *
     * Appears if selection contains: //any//     * Appears if selection contains: //any//
- 
- 
  
 ==== Setting an image as the desktop background ==== ==== Setting an image as the desktop background ====
Line 183: Line 172:
 **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. **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.
  
-==== Using 'nano' text editor ==== +==== Using 'nano' text editor in a terminal ==== 
-    * Command: ''terminal -x nano %f''+    * Name: **Open in Terminal** 
 +    * Command: xfce4-terminal -x nano %f 
 +    *  File pattern: * 
 +    * Appearance Conditions: Text files 
  
 Since nano isn't a GUI app, you must start it in a terminal window. Since nano isn't a GUI app, you must start it in a terminal window.
Line 194: Line 187:
     * Appears if selection contains: Directories and Text files     * Appears if selection contains: Directories and Text files
  
-**Note:** You will need ''meld'' package.+**Note:** You will need the ''meld'' package.
  
-==== Changing OpenOffice.org supported formats ====+==== Changing OpenDocument-supported formats ====
 **Note:** You will need ''unoconv'' package for all following actions. **Note:** You will need ''unoconv'' package for all following actions.
  
Line 216: Line 209:
     * Appears if selection contains: Video Files     * Appears if selection contains: Video Files
  
-**Note:** You will need ''python-periscope'' package. Get it [[http://code.google.com/p/periscope/|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.+**Note:** You will need ''python-periscope'' package. Get it [[http://code.google.com/p/periscope/|here]]. You'll also need ''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.
 ==== Rename subtitles easily ==== ==== Rename subtitles easily ====
     * Name: **Rename subtitles**     * Name: **Rename subtitles**
Line 224: Line 217:
     * Appears if selection contains: Video Files, Text Files, Other Files     * Appears if selection contains: Video Files, Text Files, Other Files
  
-**Note:** You will need ''subrnm'' script. Get it [[http://pastebin.com/DA8jwHz3|here]]. You'll also neeed ''zenity'' package.+**Note:** You will need ''subrnm'' script. Get it [[http://pastebin.com/DA8jwHz3|here]]. You'll also need ''zenity'' package.
  
-==== Resize and email images ==== +==== Move files into a new folder ==== 
-     * Name: **Resize Images then email them** +    * Name: **Move into new folder** 
-     * Description: Select Image files and resize them before sending in emailLeaves originals untouched+    * Description: Select any number of file/folders. A dialog will popup in which you can write the name of a new folder to createSelected Files will be moved there
-     File pattern+    CommandNEW_FOLDER=$(/usr/bin/zenity --entry --title "Move into new folder--text "Please enter a name for the new folder"); mkdir $NEW_FOLDER; mv %F $NEW_FOLDER  
-     * Appears if selection contains: Image files +    File pattern: * 
-** Note:** You will need the script here (which I name thunar-resize-sendto and place in /usr/local/bin), "zenity", and "imagemagickpackages. I used the xfce-newmail icon. Use the following command line:\\ +    Appears if selection contains: All
-/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.+
  
-<code> +**Note:** You'll will need the ''zenity'' package.
-#!/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 +[[|Back To Top]] 
-  n=$(basename "$f")  +---- 
-  echo "item '$f'->$TEMP/$n" >>$LOG +[[:xfce:thunar:|Back to Thunar documentation page]]
-  convert $f -resize $SIZE "$TEMP/$n" +
-  FILES="$FILES $TEMP/$n" +
-done +
-$SENDTO $FILES +
-</code>+