Post Your Thunar Custom Actions Here

Here you can discuss every aspect of Debian. Note: not for support requests!

Re: Post Your Thunar Custom Actions Here

Postby sir fer » 2010-02-20 23:45

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
sir fer
 
Posts: 923
Joined: 2008-09-10 18:49
Location: Auckland

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-21 00:15

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!
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-21 01:33

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
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby bugsbunny » 2010-02-24 12:43

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
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-24 13:12

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?
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby bugsbunny » 2010-02-24 21:35

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.
User avatar
bugsbunny
 
Posts: 5355
Joined: 2008-07-06 17:04

Re: Post Your Thunar Custom Actions Here

Postby dbbolton » 2010-02-25 04:36

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.
GitHub | zsh docs in Letter PDF

Telemachus wrote:Put down the CGI.
User avatar
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

Postby nadir » 2010-02-25 05:12

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.
"I am not fine with it, so there is nothing for me to do but stand aside." M.D.
User avatar
nadir
 
Posts: 5964
Joined: 2009-10-05 22:06
Location: away

Re: Post Your Thunar Custom Actions Here

Postby dbbolton » 2010-02-25 06:07

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.
GitHub | zsh docs in Letter PDF

Telemachus wrote:Put down the CGI.
User avatar
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

Postby ComputerBob » 2010-02-25 15:15

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.
ComputerBob - Making Geek-Speak Chic (TM)
ComputerBob.com - Nearly 6,000 Posts and 22 Million Views
My Ministry
My Massive Stroke
User avatar
ComputerBob
 
Posts: 1195
Joined: 2007-11-30 04:49
Location: The Beautiful Sunshine State

Re: Post Your Thunar Custom Actions Here

Postby Telemachus » 2010-02-25 15:33

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.
"We have not been faced with the need to satisfy someone else's requirements, and for this freedom we are grateful."
Dennis Ritchie and Ken Thompson, The UNIX Time-Sharing System
User avatar
Telemachus
 
Posts: 4677
Joined: 2006-12-25 15:53

Re: Post Your Thunar Custom Actions Here

Postby ComputerBob » 2010-02-25 15:56

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.
Last edited by ComputerBob on 2010-02-26 18:56, edited 1 time in total.
ComputerBob - Making Geek-Speak Chic (TM)
ComputerBob.com - Nearly 6,000 Posts and 22 Million Views
My Ministry
My Massive Stroke
User avatar
ComputerBob
 
Posts: 1195
Joined: 2007-11-30 04:49
Location: The Beautiful Sunshine State

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-26 17:17

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
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-27 13:48

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
Wisdom from my inbox: "do not mock at your pottenocy"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby dbbolton » 2010-03-02 01:27

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?
GitHub | zsh docs in Letter PDF

Telemachus wrote:Put down the CGI.
User avatar
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

PreviousNext

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 14 guests

fashionable