Page 1 of 4

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-20 23:45
by sir fer
The mplayer one is a great idea, I have been struggling for a week to get it to repeat playlists and now it works. Also I was using PCmanFM , and I only wish thunar had tabs...oh well, maybe soon

thanks Julian

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-21 00:15
by julian67
nabilalk wrote:@julian67: I registered just to say thanks for the Mount/Unmount images custom action. This is by far the easiest way to mount/unmount ISO images that I have found. What I especially like is that the image is mounted in the same location of the image file itself. Likewise, you are able to directly unmount the image from the same folder. This far and away beats using an app like FuriusISO or other custom actions that mount the image in /media. Thanks julian67 :mrgreen:
I knew about Furius ISO Mount but it's completely Gnome dependent, and who really wants a big chunk of another desktop environment and yet another GUI application for a task that can be accomplished with two short commands? I'd seen someone else post somewhere about a fuseiso Thunar action but his action didn't allow mounting images outside of ~/ such as on external media (USB/SATA). So I Read The Fine Manual and realised it's actually very simple. One of the things I like a lot about Thunar is that its simplicity (which some people confuse with lack of ability) lets the user take great advantage of all those hundreds (thousands?) of command line utilities, all from within the file manager itself and in a completely customisable way. The magic is in the man pages :D
sir fer wrote:The mplayer one is a great idea, I have been struggling for a week to get it to repeat playlists and now it works. Also I was using PCmanFM , and I only wish thunar had tabs...oh well, maybe soon

thanks Julian
You're welcome, that's what this thread is all about. And I'm enjoying the info in everyone's contributions too. I started this thread because apart from the documentation kindly linked by ComputerBob I didn't find anything similar elsewhere that was very useful. There are plenty of posts in various places about one custom action or another but no coherent body of posts, so it seemed a good idea to try to prompt people to contribute and make a good collection that could serve as a useful resource.

If you can do it on the command line you can probably do it with Thunar so, .....keep reading those man pages!

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-21 01:33
by julian67
mephjones wrote:I use this ugly hack for encryption. Any suggestions for improvement? (Requires zenity)

Code: Select all

xterm -e 'zenity --text "Enter Passphrase:" --entry --hide-text| gpg --passphrase-fd 0 -c %f'

Try this:

Code: Select all

xfce4-terminal --hide-menubar --hide-toolbars --geometry=70x10 -x gpg -c %f

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-24 12:43
by bugsbunny
For mounting/unmounting images I use a modified method, adapted from a nautilus action I was running (my desktop is out of commission due to hardware problems (either power supply or motherboard) so I'm now on a laptop that isn't completely configured yet, but I'm close. Using xfce on this setup)

Instead of calling fuseiso directly I call a bash script. This enables me to mount (and unmount) multiple images in 1 shot. When mounting the last iso mounted gets opened in your file manager (thunar by default).

Mountpoints are on your desktop, but you can easily change that. I store the scripts in ~/bin/

mountiso script

Code: Select all

#!/bin/bash
while [ $1 ]; do
  ISONAME=${1##*/}
  mkdir ~/Desktop/"$ISONAME".mount
  fuseiso "$1" ~/Desktop/"$ISONAME".mount|| rmdir ~/Desktop/"$ISONAME".mount
  sleep 1
  shift
done
[ -d ~/Desktop/"$ISONAME".mount ] && exo-open ~/Desktop/"$ISONAME".mount >/dev/null
exit
umountiso script

Code: Select all

#!/bin/bash
while [ $1 ]; do
  fusermount -uz "$1"
  rmdir "$1"
  shift
done
exit
the "actions" definition uses %F rather than %f so:
to mount: ~/bin/mountiso %F
to unmount: ~/bin/umountiso %F
Appearance conditions match Julian's

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-24 13:12
by julian67
Looks good. I'd not considered mounting multiple images (quiet life I lead) but I'm wondering if much the same (less the automatic file manager open) can be accomplished by using the same action I posted but with %F instead of %f, or do you need the sleep 1 to keep it reliable?

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-24 21:35
by bugsbunny
julian67 wrote:Looks good. I'd not considered mounting multiple images (quiet life I lead) but I'm wondering if much the same (less the automatic file manager open) can be accomplished by using the same action I posted but with %F instead of %f, or do you need the sleep 1 to keep it reliable?
I'm not sure, reading the fusermount man page it doesn't look like it will accept multiples in one shot, and I don't remember if I tested that way originally (although knowing me I probably did). I'm pretty sure that I added the sleep 1 because otherwise it wasn't reliable back when I was originally setting this up, but that was quite a while ago (via nautilus).

However I may still be able to simplify things on both the mount and unmount side. Reading the fusermount page just now I saw the -p option (at least with the version in testing).
-p
maintain mount point; create it if it does not exist and delete it
on exit.
If I read that right I can skip creating the mountpoint and simplify things as follows (untested as of now):
mountiso:

Code: Select all

#!/bin/bash
while [ $1 ]; do
  ISONAME=${1##*/}
  fuseiso -p "$1" ~/Desktop/"$ISONAME".mount
  sleep 1
  shift
done
[ -d ~/Desktop/"$ISONAME".mount ] && exo-open ~/Desktop/"$ISONAME".mount >/dev/null
exit
and umountiso then becomes:

Code: Select all

#!/bin/bash
while [ $1 ]; do
  fusermount -uz "$1"
  shift
done
exit
You can try removing the sleep command, it may work.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-25 04:36
by dbbolton
I attempted to add a confirmation dialog to my rm action, but for some reason it doesn't work on files whose names contain spaces. I never give a file a name with a space, but occasionally I will come across one (e.g. a download), and I wouldn't want to have to rename it in order to use this action.

Here is the script I used:

Code: Select all

#!/bin/bash
zenity --question --text "rm selected files?" ; ans=$?

if [ $ans = 0 ]; then
	for i in $@
	do
		rm -fvr \"$i\" >> $HOME/rm.log
	done
fi
I also tried it without the backslashes before the quotes. If I try to remove a file through this action, let's say, called "copy of file.txt", the log file will contain the line

Code: Select all

removed `file.txt'
provided that "file.txt" actually exists, suggesting that rm is still treating the things on either side of a space as different files. Of course,

Code: Select all

rm "copy of file.txt" 
will actually remove the copy file when I issue such a command on the command line.

Any suggestions?

I suppose I could write a perl script to substitute "\ " with "\\\ ", but that seems unnecessary.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-25 05:12
by nadir
not a foo-master of bash or thunar, but "$@" and "$i" (instead of $@ and \"$i\" ) worked here:
markus@Refracta:$ cat rm.log
removed `/home/markus/Pictures/screenshots/2010-01-06-201852.png'
removed `/home/markus/test file.txt'
if thats what you wanted.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-25 06:07
by dbbolton
nadir wrote:not a foo-master of bash or thunar, but "$@" and "$i" (instead of $@ and \"$i\" ) worked here:
markus@Refracta:$ cat rm.log
removed `/home/markus/Pictures/screenshots/2010-01-06-201852.png'
removed `/home/markus/test file.txt'
if thats what you wanted.
That seems to do the trick. Thanks.

I also just realized that I don't need to use that temporary variable either.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-25 15:15
by ComputerBob
I've changed my Firefox to several different character encodings, but, in Nadir's posts, I see what looks like a tall, thin, capital letter "S" wearing a hat and a tail (instead of a dollar-sign), and the letter that immediately follows the first "S" looks like a circle with a triangle inside of it.

That occurs in Nadir's posts themselves, in Nadir's quoting of dbbolton's post, and in dbbolton's quoting of Nadir's posts, but it doesn't occur in dbbolton's original post.

So when Nadir posted that he used "xx instead of xx", they both look like the exact same code to me, and they're both unreadable.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-25 15:33
by Telemachus
ComputerBob wrote:I've changed my Firefox to several different character encodings, but, in Nadir's posts, I see what looks like a tall, thin, capital letter "S" wearing a hat and a tail (instead of a dollar-sign), and the letter that immediately follows the first "S" looks like a circle with a triangle inside of it.

That occurs in Nadir's posts themselves, in Nadir's quoting of dbbolton's post, and in dbbolton's quoting of Nadir's posts, but it doesn't occur in dbbolton's original post.

So when Nadir posted that he used "xx instead of xx", they both look like the exact same code to me, and they're both unreadable.
I think you just broke my brain.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-25 15:56
by ComputerBob
Telemachus wrote: I think you just broke my brain.
So now there are two of us. :lol:

Basically, what I was trying to say is that, apparently due to some unknown character encoding problem, Nadir's coding suggestion is appearing to me as weird, unreadable characters, both in Nadir's posts and in dbbolton's quoting of Nadir's posts.

UPDATE: See this other thread for the solution.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-26 17:17
by julian67
Extract Images from PDF and save to 300 DPI jpg

Requires ImageMagick and the very latest version of ghostscript (version released in Debian Testing this week solves a bug handling pdf files which don't comply with Adobe's PDF specification).

This works fine without using xterm, but if you want to see what it's doing you could prefix the action with 'xterm -hold -e ' or 'xfce4-terminal -H -x '

Put the script in your path and make it executable.

If you're running Lenny, or any system with Ghostscript <8.71 then use the second script below. It's somewhat slower, having two conversion stages, but it works fine.

Image

script

Code: Select all

#!/bin/sh
# pdf2jpg extracts images from pdf and saves them in same directory at 300 dpi as booklet-#.jpg
# i.e. booklet-0.jpg,booklet-1.jpg and so on
# the numbering is automatic.
for FILE in "$@" ; do
convert -define pdf:use-cropbox=true -quality 100% -density 300 "$FILE" booklet.jpg
done
alternative script for systems using older versions of ghostscript (requires xpdf-utils,ImageMagick):

Code: Select all

#!/bin/sh
# pdf2jpg extracts images from pdf and saves them in same directory at 300 dpi as booklet-#.jpg
# i.e. booklet-0.jpg,booklet-1.jpg and so on
# the numbering is automatic.
for FILE in "$@" ; do
OUTFILE=$(dirname "$FILE")/booklet.jpg
pdftoppm -cropbox "$FILE" "$FILE" ;
convert "$FILE"*.ppm -density 300 -quality 100% "$OUTFILE" ;
rm "$FILE"*.ppm
done

Re: Post Your Thunar Custom Actions Here

Posted: 2010-02-27 13:48
by julian67
Convert Video for Sansa Fuze:

Will convert all selected video files for playback on Fuze.

Requires fuzemux and mencoder script, see http://forums.debian.net/viewtopic.php?p=286477#p286477

Image

Get fuzemux from http://code.google.com/p/fuzemux/

MEncoder script:

Code: Select all

#!/bin/bash
# script name mensansa

for MOVIE in "$@" ; do

# Get movie name and strip extension - allow spaces dots etc
VIDOUT=$(basename "$MOVIE" |sed 's/\(.*\)\..*/\1/')

# Get original directory name of movie
DIRNAME=$(dirname "$MOVIE")

# Set output directory & name for converted movie
DEST="$DIRNAME"/"$VIDOUT"_fuze.avi

mencoder "$MOVIE" \
-srate 44100 -af resample=44100:0:1,format=s16le \
-oac mp3lame -lameopts cbr:br=128 \
-ovc lavc -lavcopts vcodec=mpeg4:vqscale=3:vmax_b_frames=0:keyint=15 \
-ofps 20 -noskiplimit -vf pp=li,expand=:::::224/176,scale=224:176 \
-ffourcc DX50 \
-o "$MOVIE"_premux.avi \
&& fuzemux "$MOVIE"_premux.avi "$DEST" \
&& rm "$MOVIE"_premux.avi
done

Re: Post Your Thunar Custom Actions Here

Posted: 2010-03-02 01:27
by dbbolton
I have no idea why, but my "rm" action doesn't work on my new system. The action is set up as "rm-dialog %F" just like on my old one.

$HOME/bin/rm-dialog

Code: Select all

#!/bin/bash
zenity --question --text "rm selected files?"
if [ $? = 0 ]; then
	rm -fvr "$@" >> $HOME/log
fi
echo $@ >> $HOME/log
then the log file will look like this:

Code: Select all

removed `/home/daniel/source/test'
/home/daniel/source/wmii /home/daniel/source/test
wmii is a directory, but as you can see I have the r flag in the command. Any thoughts?

Re: Post Your Thunar Custom Actions Here

Posted: 2010-03-02 02:08
by julian67
I just tried your rm-dialog script both from the shell and as a Thunar custom action and it's working fine here. I tried it again with set -x and no unexpected output. I suspect you may have either forgotten to set it executable, or it's executable but not in your path, or you have something in your .bashrc/aliases/functions which is conflicting. Or maybe you're trying to remove files/dirs for which you don't have write permissions.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-03-02 02:36
by dbbolton
julian67 wrote:I just tried your rm-dialog script both from the shell and as a Thunar custom action and it's working fine here. I tried it again with set -x and no unexpected output. I suspect you may have either forgotten to set it executable, or it's executable but not in your path, or you have something in your .bashrc/aliases/functions which is conflicting. Or maybe you're trying to remove files/dirs for which you don't have write permissions.
Well, I did chmod +x the script file-- twice in fact. It's definitely in my path and running. The zenity box shows up, and I clicked "Ok". I don't have any rm-related aliases for my regular user account.

I created that directory with that regular user account too, but I will check to see whether there are any files therein for which I lack write privileges. Still, I would have suspected "permission denied" or something of the like to show up, since the -v flag was on. Anyhow, thanks for the tips.

Also, if you are willing to add them, I think your custom actions would make a great addition to the wiki. You might be surprised how often a search result leads me thither rather than hither.

P.S. Breaking Bad is great.

Re: Post Your Thunar Custom Actions Here

Posted: 2010-03-06 07:10
by sir fer
dbbolton wrote: P.S. Breaking Bad is great.
Yeah it's good eh...Who'd have thought Malcolms dad could be such badazz?

Re: Post Your Thunar Custom Actions Here

Posted: 2010-03-06 16:02
by canci
Thank you all so much for this wonderful post! I've been trying out various file managers over the years and Thunar just seems to be
the best when it comes to being similar to my experience with old pre XP Windows Explorer and being lean and fast enough
for a WM. Shamefully, I have no script to contribute, though I've always wanted to adapt a batch conversion script for Imagemagick.
Stay tuned, maybe I will.

@sir fer: Regarding Thunar's lack of tabs. If you use Fluxbox, you can set its apps file to group every Thunar window, thus, if
clicked on "Open New Window", it will instead tab it with the old one.

See: http://fluxbox-wiki.org/index.php?title ... _apps_file under "Grouping apps via the apps file"

I just wish Openbox could do that. Hmm...

Re: Post Your Thunar Custom Actions Here

Posted: 2010-03-06 16:19
by julian67
A neat way for batch image conversions as a Thunar Custom Action is to use Phatch. Phatch: PHoto bATCH. It's in Debian main from Lenny onwards. Phatch works on the command line as well as via a GUI, and running an action as a command is really easy. For example I have an action to reduce image size to 70%, mostly used to get fullscreen screenshots down to a reasonable size. I made the action using the GUI and saved it to ~/.local/share/phatch/actionlists/screens.phatch (I believe the older versions of Phatch such as Lenny's use a different save location). So now I have a custom action:

Image

Code: Select all

phatch ~/.local/share/phatch/actionlists/screens.phatch %F
Phatch has a large range of available actions built in:
* Auto Contrast - Maximize image contrast
* Background - Put colour under transparent image
* Border - Variable border to the inside or outside
* Brightness - Adjust brightness from black to white
* Canvas - Crop the image or enlarge canvas without resizing the image
* Color To Alpha - Make a background with fixed color transparent
* Colorize - Colorize grayscale image
* Common - Copies the most common pixel value
* Contour - Draw a contour around image edges
* Contrast - Adjust from grey to black & white
* Convert Mode - Convert the color mode of an image (grayscale, RGB, RGBA or CMYK)
* Copy - Copy image file
* Crop - Crop the image
* Delete Tags - Delete Exif or Iptc Tags
* Desaturate - Fade all colors to grey
* Effect - Blur, Sharpen, Emboss, Smooth, …
* Equalize - Equalize the image histogram
* Fit - Downsize and crop image with fixed ratio
* Geek - Execute external command
* Geotag - Geotag an image file
* Grayscale - Fade all colours to gray
* Highlight - Add a highlight effect
* Imagemagick - Blur, Polaroid, Shadow, Unsharp…
* Invert - Invert the colors of the image (negative)
* Lossless JPEG - Rotate, flip, grayscale and crop
* Maximum - Copies the maximum pixel value
* Mask - Apply a transparency mask
* Median - Copies the median pixel value
* Minimum - Copies the minimum pixel value
* Mirror - Symmetrical tile texture
* Offset - Offset by distance and wrap around
* Perspective - Shear 2d or 3d
* Posterize - Reduce the number of bits of colour channel
* Rank - Copies the rank'th pixel value
* Reflect - Drops a reflection
* Rename - Rename image file
* Rename Tag - Rename an Exif or Iptc Tag
* Rotate - Rotate with random angle
* Round - Round or crossed corners with variable radius and corners
* Saturation - Adjust saturation from grayscale to high
* Save - Save an image with variable compression in different types
* Save Tags - Save only metadata (lossless)
* Scale - Scale an image with different resample filters.
* Shadow - Drop a blurred shadow under a photo with variable position, blur and color
* Sketch - Transform to a grayscale pencil drawing.
* Solarize - Invert all pixel values above threshold
* Tamogen - Tone altering mosaic generator
* Text - Write text at a given position
* Time Shift - Shift Exif time
* Transpose - Flip or rotate an image by 90 degrees
* Watermark - Apply a watermark image with variable placement (offset, scaling, tiling) and opacity
* Write Tag - Write a new value to a metadata tag (exif & iptc)
And you can make your own too http://photobatch.wikidot.com/writing-actions