Diff for "ThunarCustomActions"


Differences between revisions 7 and 8
Revision 7 as of 2015-10-16 08:30:37
Size: 13835
Editor: 97e20e88
Comment:
Revision 8 as of 2016-07-16 22:38:21
Size: 13838
Editor: slickymaster
Comment: Corrected the program required to run the command in 'Copy Current Path' section per http://docs.xfce.org/xfce/thunar/custom-actions#saving_the_selected_filefolder_s_pathname_to_the_clipboard
Deletions are marked like this. Additions are marked like this.
Line 108: Line 108:
echo -n %f | xclip -selection "clipboard" xclip program to be installed on your system

Discussion of this wiki can be found here

Thunar Custom Actions

If you like the Thunar file manager (default in Xubuntu), you will probably love custom actions. These are user-defined commands that act upon selected files in Thunar. Either on their own, or combined with a simple dialog app such as Zenity, these can be very powerful and useful.

Thunar > Edit > Configure custom actions will take you to the dialog for creating and organising your custom actions. However, because this is GUI-oriented, the easiest way to install someone else's custom action is through a bash command. This is a list of a number of custom actions contributed by the Ubuntu community.

ffmpeg -i %f 2>&1 | grep -e Stream -e Duration -e Input | zenity --width=800 --height=240 --text-info --title %n

Delete/Bypass Recycle Bin

Command:

rm -r

Description: Removes the selected file(s) from the disk, bypassing any local Recycle bin. Useful when in samba shares. Requires confirmation for reasons of safety.
Requires: zenity

CONTENT='<action><icon>stock_delete</icon><name>Remove...</name><command>zenity --question --title=&quot;Remove...&quot; --window-icon=&quot;/usr/share/icons/Tango/16x16/actions/edit-delete.png&quot; --text=&quot;Do you wish to permanently\nremove the selected file(s)?&quot; ; if [ $? = 0 ] ; then rm -r %F ; fi</command><description>Permanently remove the selected file(s)</description><patterns>*</patterns><directories/><audio-files/><image-files/><other-files/><text-files/><video-files/></action>'
cat $HOME/.config/Thunar/uca.xml >> newtmp
sed 's/<\/actions>//' <newtmp >newfile
echo $CONTENT >> newfile
mv $HOME/.config/Thunar/uca.xml $HOME/.config/Thunar/uca.xml.bak
mv newfile $HOME/.config/Thunar/uca.xml
rm newtmp

Command:

ln -s

Description: Creates an absolute symbolic link to the selected file in the same folder, which can then be moved or renamed as desired. man ln for more info.
Requires:

CONTENT='<action><icon>emblem-symbolic-link</icon><name>Create Symlink</name><command>ln -s %f %n.symlink</command><description>Creates a symbolic link to the selected object</description><patterns>*</patterns><directories/><audio-files/><image-files/><other-files/><text-files/><video-files/></action>'
cat $HOME/.config/Thunar/uca.xml >> newtmp
sed 's/<\/actions>//' <newtmp >newfile
echo $CONTENT >> newfile
mv $HOME/.config/Thunar/uca.xml $HOME/.config/Thunar/uca.xml.bak
mv newfile $HOME/.config/Thunar/uca.xml
rm newtmp

Permanently Remove

Command:

Xdialog --title "Remove..." --yesno "Do you wish to permanently remove \n %N?" 10 45 &amp;&amp; rm -r %F

Description: Permanently remove selected files. Appears if selection contains any files.
Requires: Xdialog

<action><icon></icon><name>Permanently remove...</name><command>Xdialog --title &quot;Remove...&quot; --yesno &quot;Do you wish to permanently remove n %N?&quot; 10 45 &amp;&amp; rm -r %F</command><description>Permanently remove selected files</description><patterns>*</patterns><directories/><audio-files/><image-files/><other-files/><text-files/><video-files/></action>  

Join

Command:

cat %F &gt; joined.txt

Description: Join selected text files. Appears if selection contains text files.
Requires:

<action><icon></icon><name>Join</name><command>cat %F &gt; joined.txt</command><description>Join selected text files</description><patterns>*</patterns><text-files/></action>  

View

Command:

feh %F

Description: View selected images in a slideshow. Appears if selection contains image files.
Requires: feh

<action><icon></icon><name>View</name><command>feh %F</command><description>View selected images in a slideshow</description><patterns>*</patterns><image-files/></action>  

Play 15 seconds

Command:

mplayer %f -really-quiet -endpos 15

Description: Play a 15 seconds clip of a media file. Appears if selection contains: audio files, video files
Requires: mplayer

<action><icon></icon><name>Play 15 seconds</name><command>mplayer %f -really-quiet -endpos 15</command><description>Play a 15 seconds clip of a media file</description><patterns>*</patterns><audio-files/><video-files/></action>  

Copy Current Path

Command:

echo -n %f | xclip -selection "clipboard"

Description: Copies $PATH to clipboard.
Requires:

xclip program to be installed on your system

Open Terminal Here

Command:

urxvtc -cd %f

Description: Opens terminal in current directory.
Requires: urxvt client

urxvtc -cd %f

Extract Archive Here

Command:

squeeze -x . %N

Description: Extracts archive to current directory.
Requires: squeeze

squeeze -x . %N

Extract Passworded Archive

Command:

xarchiver -e %N

Description: Extracts passworded archive to current directory.
Requires: xarchiver

xarchiver -e %N

Estimated Space Usage

Command:

du -chs --apparent-size %N | zenity --text-info

Description: Estimates disk space usage.
Requires: zenity

du -chs --apparent-size %N | zenity --text-info

Create Archive Here

Command:

squeeze -n %N

Description: Creates archive in current directory.
Requires: squeeze

squeeze -n %N

Sign Using GnuPG

Command:

terminal -e "gpg -a -u [user] -b %f"

Description: Signs a file with the user's GPG key.
Requires: gpg

terminal -e "gpg -a -u [user] -b %f"

Encrypt Using GnuPG

Command:

terminal -e "gpg -e -r [recipient] %f"

Description: Encrypts a file using GPG.
Requires: gpg

terminal -e "gpg -e -r [recipient] %f"

Decrypt GnuPG File

Command:

terminal -e "gpg -o %n.decrypted -d %f"

Description: Decrypts GnuPG file, appending ".decrypted" to the decrypted filename.
Requires: gpg

terminal -e "gpg -o %n.decrypted -d %f"

Shred and Delete File(s)

Command:

zenity --question;if [$? = 0];then shred -fuz %F;fi

Description: Shreds and deletes file.
Requires: zenity

zenity --question;if [$? = 0];then shred -fuz %F;fi

Add to iPod

Command:

gnupod_addsong.pl %F | Xdialog --title "GNUpod - Add song" --no-cancel --tailbox - 24 64

Description: Adds songs to iPod. Appears if selection contains audio or video files.
Requires: gnupod, Xdialog

<action><icon></icon><name>Add to Ipod</name><command>gnupod_addsong.pl %F | Xdialog --title &quot;GNUpod - Add song&quot; --no-cancel --tailbox - 24 64</command><description>Add songs to Ipod</description><patterns>*.mp3;*.m4a;*.mp4</patterns><audio-files/><video-files/></action> 

Open Folder As Root

Command:

pkexec thunar %f

Description: Opens current folder with root permissions.
Requires:

pkexec thunar %f

Open Text as Root

Command:

pkexec mousepad %f

Description: Opens selected text file with root permissions. Substitute the name of your editor of choice for "gedit".
Requires: text editor

pkexec mousepad %f

Search Including Hidden Files/Folders

Command:

catfish --fileman=thunar --hidden --path=%f

Description: Searches entire filesystem.
Requires: catfish

catfish --fileman=thunar --hidden --path=%f

Mount ISO

Command:

gksudo mount -o loop -t iso9660 %f /mnt'

Description: Mounts .iso files.
Requires:

gksudo mount -o loop -t iso9660 %f /mnt

Convert To AVI

Command:

xfce4-terminal -x ffmpeg -i %f -b 798k -ab 128k %f.avi

Description: Converts video file to .avi.
Requires: ffmpeg

xfce4-terminal -x ffmpeg -i %f -b 798k -ab 128k %f.avi

Add Progress Bar To Copy

Command:

(for I in $(seq 2); do echo $I; sleep 1; done; cp %F "/destination/folder") | zenity --progress --pulsate --auto-close

Description: Adds progress bar to copy/paste.
Requires: zenity

(for I in $(seq 2); do echo $I; sleep 1; done; cp %F "/destination/folder") | zenity --progress --pulsate --auto-close

Change Multiple File Permissions

Command:

Description: Allows user to change file permissions of one or multiple files with small GUI.
Requires: zenity

ans=$(zenity  --height=350 --list  --text "change files permissions" --checklist  --column "pick" --column "options" TRUE "user-read" TRUE "user-write" FALSE "user-exec" FALSE "group-read" FALSE "group-write" FALSE "group-exec" FALSE "all-read" FALSE "all-write" FALSE "all-exec" --separator=":"); if [ "$ans" != "" ]; then searchuserread="user-read"; searchuserwrite="user-write"; searchuserexec="user-exec"; user1="0" ; user2="0" ; user3="0" ; searchgroupread="group-read"; searchgroupwrite="group-write"; searchgroupexec="group-exec"; group1="0" ; group2="0" ; group3="0" ; searchallread="all-read"; searchallwrite="all-write"; searchallexec="all-exec"; all1="0" ; all2="0" ; all3="0" ; case $ans in  *"$searchuserread"*) user1="4" ;; esac ; case $ans in  *"$searchuserwrite"*) user2="2" ;; esac ; case $ans in  *"$searchuserexec"*) user3="1" ;; esac ; case $ans in  *"$searchgroupread"*) group1="4" ;; esac ; case $ans in  *"$searchgroupwrite"*) group2="2" ;; esac ; case $ans in  *"$searchgroupexec"*) group3="1" ;; esac ; case $ans in  *"$searchallread"*) all1="4" ;; esac ; case $ans in  *"$searchallwrite"*) all2="2" ;; esac ; case $ans in  *"$searchallexec"*) all3="1" ;; esac ; u=$(($user1 + $user2 + $user3)) ; g=$(($group1 + $group2 + $group3)) ; a=$(($all1 + $all2 + $all3)) ; result="$u$g$a" ; chmod $result %F || { zenity --error --text="an error occurred!\ncheck if you are allowed\nto change permissions\nof the selected files"; } ; fi

Move Files From Subfolders To Parent Folder

Command:

find . -mindepth 2 -type f -exec mv "{}" . \;

Description: Moves files from subfolders to parent (current) folder.
Requires:

find . -mindepth 2 -type f -exec mv "{}" . \;

Delete All Empty Folders

Command:

find . -type d -empty -delete

Description: Deletes all empty folders in current directory.
Requires:

find . -type d -empty -delete

Encrypt/Decrypt using BCrypt

Command:

Description: Uses bcrypt to encrypt/decrypt files.
Requires: zenity, bcrypt

zenity --info  --title="Impending Bcrypt Operation" --window-icon="/usr/share/pixmaps/keybox.png" --text="There is a bcrypt operation impending.  Watch inside the File Manager window to verify that said operation is successful." ; : ; while [ "$?" = "0" ] ; do xterm -e bcrypt %F ; sleep 2 ; zenity --question --title="Success?" --window-icon="/usr/share/pixmaps/keybox.png" --text="Was the bcrypt operation successful?" ; if [ "$?" = "0" ] ; then exit ; fi ; zenity --question --title="Try again?" --window-icon="/usr/share/pixmaps/keybox.png" --text="Would you like to try again?" ; if [ "$?" != "0" ] ; then exit ; fi ; done

Grab Metadata From Media File

Command:

ffmpeg -i %f  2>&1 | grep -e Stream -e Duration -e Input | zenity --width=800 --height=240 --text-info --title %n

Description: Grabs info from a media (audio/video) file using ffmpeg.
Requires: ffmpeg, zenity

ffmpeg -i %f  2>&1 | grep -e Stream -e Duration -e Input | zenity --width=800 --height=240 --text-info --title %n

Edit Filesystem Metadata

Command:

eiciel %f

Description: Edit file or folder extended attributes and access control lists
Requires: eiciel

<action>
        <icon>document-properties</icon>
        <name>Extended attributes</name>
        <command>eiciel %f</command>
        <description>Edit extended attributes and permissions</description>
        <patterns>*</patterns>
        <directories/>
        <audio-files/>
        <image-files/>
        <other-files/>
        <text-files/>
        <video-files/>
</action>

Open anything as Superuser

Command:

gksudo exo-open %f

Description: Launch any file or folder with superuser privileges

<action>
        <icon>category-show-all</icon>
        <name>Open as superuser</name>
        <command>gksudo exo-open %f</command>
        <description>Open file/folder with full privileges</description>
        <patterns>*</patterns>
        <startup-notify/>
        <directories/>
        <audio-files/>
        <image-files/>
        <other-files/>
        <text-files/>
        <video-files/>
</action>


Another good source of custom actions can be found in the Thunar wiki.


Originally posted The Ubuntu Forums (ubuntuforums.org)

ThunarCustomActions (last edited 2020-11-26 12:49:36 by serhii-gipsy)