Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Post Your Thunar Custom Actions Here

Here you can discuss every aspect of Debian. Note: not for support requests!
Message
Author
User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Post Your Thunar Custom Actions Here

#1 Post by julian67 »

Thunar seems to some people to be a very simple file manager, in fact I've seen this asserted quite a few times in various places such as reviews, blogs, vitriolic trolling complaints and so on. It's not actually true but it does look quite limited if you don't care to scratch the surface, read a doc or even just click around with your mouse and see what lurks in the menu. But in fact it's far more versatile than first appearances suggest because it supports custom actions (user created context menu entries) in a very neat way, making it possible to create even quite complex actions very easily and take advantage of the applications and utilities on your system, all from within the file manager. Post your favourites here!

A couple of simple ones:

Slideshow

This requires feh

This will take the images in the directories and/or files you select and display them in a fullscreen slideshow, 3 seconds per image. Use the keyboard h to pause the show and v to show the images actual (1:1) size.

Image

Thunar is missing one facility found in most other file managers, the ability to highlight several directories and/or files and have the total size displayed. So I made a custom action:

How Big?

Image

So I highlight some files and directories and use the 'How Big?' right click entry:

Image

and get this:

Image


I'll post a few more later, just wanted to get things started for now.

So please post your Thunar custom actions, simple or complex. Explain what they do, which applications they use, and if they call a custom script please post that as well. Ideally post screenshots as well but please keep the size reasonable and the text legible. I find scaling the dialogue boxes to 80% satisfies this, and posting a clickable thumb is better if you need to show a substantial part of the desktop.
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
bodiless
Posts: 273
Joined: 2007-01-24 14:38
Location: Greece

Re: Post Your Thunar Custom Actions Here

#2 Post by bodiless »

Well, its the only I use and since nobody else replied:

To open what ever terminal you want with whatever dimensions you need in the folder you are browsing use:

Code: Select all

xfce4-terminal --geometry=70x12
This is for xfce4-terminal but you could use xterm etc.

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#3 Post by julian67 »

Patience! :D

OK so maybe nobody is interested except you and me, but anyway I'll just keep adding...

Make Playlist:

This one works on directories of audio files, flac/ape/wv/mp3/aac/ogg/oga/wma/mpc/m4a, and creates a simple m3u playlist (no paths, not extended) and changes the line endings to dos format so the playlist works in portable players. The playlist will be named with the directory name i.e. "The Beatles - Abbey Road.m3u". Requires the package tofrodos.

Code: Select all

ls -w 1 -R %n/ |egrep *.'[fF][lL][aA][cC]|[aA][pP][eE]|[wW][vV]|[wW][aA][vV]|[mM][pP][3]|[aA][aA][cC]|[oO][gG][gG]|[oO][gG][aA]|[wW][mM][aA]|[mM][pP][cC]|[mM][4][aA]' >%n/%n.m3u && todos %n/%n.m3u
Image
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#4 Post by julian67 »

Convert any and all selected audio files to Ogg Vorbis -q 7 while retaining all tags including cover art and replay gain. Filenames including spaces and bad characters such as ( or . are allowed.

edit: this and the following script requires gstreamer0.10-plugins-base & gstreamer0.10-plugins-good and the mp3 script requires gstreamer0.10-plugins-bad. For those of you who have a morbid fear of the letter g: don't worry. Gstreamer is not GTK or Gnome, has no dependencies on them and doesn't require any graphical desktop. It's a multimedia framework written in C.

Image

This requires the following script to be in your path and in this custom action it's called ogggst.sh but name it to whatever you prefer:

Code: Select all

#!/bin/bash

for TRACK in "$@" ; do

# allow filenames containing dots such as "an artist feat. some_other_artist"
OGGOUT=$(ls "$TRACK" |sed 's/\(.*\)\..*/\1/')

gst-launch filesrc location="$1" ! decodebin ! audioconvert ! \
vorbisenc name=enc quality=0.7 ! oggmux ! filesink location="$OGGOUT.ogg"
done
Last edited by julian67 on 2010-02-16 21:34, edited 1 time in total.
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#5 Post by julian67 »

Convert any and all selected audio files to mp3 VBR (using Lame quality V 4) while retaining all tags including cover art (but not replay gain). This writes the tags with ID3v2.3 but doesn't write ID3v1.1 or 2.4. This makes the tags readable by any software or hardware audio player or tagging tools which aren't desperately bad or unmaintained for years. Filenames including spaces and bad characters such as ( or . are allowed.

The appearance conditions have to be slightly different than for the ogg script. Of course they need to exclude already existing mp3s, but also these days Debian sees .ogg as Video and .oga as Audio, so the condition allows Video files but the list of allowed extensions includes only likely audio types. This is my list: *.ogg;*.flac;*.wv;*.wav;*.mpc;*.ape;*.shn


Image

This requires the following script to be in your path and in this custom action it's called mp3gst.sh but name it to whatever you prefer:

Code: Select all

#!/bin/bash

for TRACK in "$@" ; do

# allow filenames containing dots such as "an artist feat. some_other_artist"
MP3OUT=$(ls "$TRACK" |sed 's/\(.*\)\..*/\1/')

gst-launch filesrc location="$TRACK" ! decodebin! audioconvert ! \
lame name=enc mode=4 vbr=4 vbr-quality=4 ! xingmux ! id3mux ! \
filesink location="$MP3OUT.mp3"
done
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
bodiless
Posts: 273
Joined: 2007-01-24 14:38
Location: Greece

Re: Post Your Thunar Custom Actions Here

#6 Post by bodiless »

So basically you could point thunar to whatever script you like. Cool :-)

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#7 Post by julian67 »

bodiless wrote:So basically you could point thunar to whatever script you like. Cool :-)
You definitely can. And you can exploit Thunar's ability to use a simple script in less simple ways. For example:

I always rip CDs to lossless, the files being written to ~/temp/flacin/$artist - $album/$tracknumber - $tracktitle. An m3u playlist is automatically created when ripping. After ripping I scan the covers/booklet and make a 300x300 pixel cover image for media player cover art, and this is always named as folder.jpg. I also correct the audio files' tags if necessary and then embed the folder.jpg in the tags. Not every application can use embedded art so I retain folder.jpg.

My music directory is ~/Music. I prefer to use Ogg Vorbis for my music directory.

I also have a Nokia device which works better with mp3 so I have another directory ~/temp/nokiatemp for stuff converted to mp3.

I don't want all my music in both vorbis and mp3, it's a very small proportion of it which I ever want as mp3.

When I'm ready to convert the flacs to ogg or mp3 I want it completely automated, so I want the tracks converted, a new directory created in ~/Music or ~/temp/nokiatemp, the encoded tracks and folder.jpg and m3u playlist all copied across and the m3u playlist corrected to show the new file extension. I also want replaygain applied in album mode.

So still using the same scripts as in the examples above:

Image

Directory to Oggs:

Code: Select all

find %f -regex ".*\(flac\|mp3\|ape\|wv\|mpc\)$" -execdir ogggst.sh {} \+ && mkdir ~/Music/%n && mv %n/*.ogg ~/Music/%n/ && cp %n/*.m3u %n/folder.jpg ~/Music/%n/ && sed -i 's/\(mp3\)\|\(flac\)\|\(ape\)\|\(mpc\)\|\(wv\)/ogg/g' ~/Music/%n/*.m3u && xterm -e vorbisgain -a ~/Music/%n/*.ogg
Directory to mp3:

Code: Select all

find %f -regex ".*\(ogg\|flac\|mpc\|ape\|wv\)$" -execdir mp3gst.sh {} \+ && mkdir ~/temp/nokiatemp/%n && mv %n/*.mp3 ~/temp/nokiatemp/%n/ && cp %n/*.m3u %n/folder.jpg ~/temp/nokiatemp/%n/ && sed -i 's/\(ogg\)\|\(flac\)\|\(ape\)\|\(mpc\)\|\(wv\)/mp3/g' ~/temp/nokiatemp/%n/*.m3u && xterm -e mp3gain -a -k ~/temp/nokiatemp/%n/*.mp3
So now in Thunar a right click on a directory followed by a left click does the lot :D

There are applications can do some or most of this but none can do all. dir2ogg is pretty good as it can create the destination directory but it doesn't retain cover art or copy the folder.jpg or playlist. Many of the mp3 batch tools still use ID3v1.1 which is beyond hopeless (it's worse than useless because it truncates long names and discards data), and none of them can handle embedded images or anything much at all except basic encoding. SoundJuicer can do quite a lot but is very limited in user set options with reference to encoding quality, ID3 tag version, and destination directory (only really works with directories if every track has the same artist). Foobar2000 can run in wine and is very capable but discards all embedded images on encoding and seems unreliable with UNIX style paths (encoding fails).

So eventually I'll have a few directories of lossless music in ~/temp/flacin and I'd like to archive them. There's no point in using compression (they are already losslessly compressed) so I prefer a .tar archive....time for another custom action:

This requires atool to be installed

Code: Select all

apack -e -F tar %N
This will take each directory highlighted (or file) and pack each into its own individual tar archive.
Last edited by julian67 on 2010-02-19 00:02, edited 1 time in total.
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
dbbolton
Posts: 2129
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

#8 Post by dbbolton »

To remove selected files rather than merely send them to the "trash":

Code: Select all

rm -fr %F
To set the wallpaper with feh:

Code: Select all

feh --bg-scale %f
feh --bg-center %f
To open a file in a new tab in Kate:

Code: Select all

kate -u %f
GitHub | zsh docs in Letter PDF
Telemachus wrote:Put down the CGI.

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#9 Post by julian67 »

Mount and unmount ISO, BIN, IMG, MDF disk images:

This requires fuseiso and that the user is a member of the fuse group.

Mount:

Image

command:

Code: Select all

fuseiso -n -p %f %f.mount
appearance conditions:

Code: Select all

*.iso;*.ISO;*.bin;*.BIN;*.nrg;*.NRG;*.mdf;*.MDF
Unmount:

Image

command:

Code: Select all

fusermount -u %f
appearance conditions:

Code: Select all

*.mount
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
gnutonian
Posts: 71
Joined: 2009-12-28 18:51
Location: France

Re: Post Your Thunar Custom Actions Here

#10 Post by gnutonian »

julian67 wrote:Patience! :D

OK so maybe nobody is interested except you and me, but anyway I'll just keep adding...
I'm interested. I'll definitely steal a few of your actions when I've got a day off. Unfortunately, for now, I've got nothing to add myself as I've never gotten around to making my own custom actions.
"Mankind is advanced technically. Man can build space stations, can assemble them in space, and ponders about landing on Mars, but the development of mankind itself seems to stagnate on stone age level." - Sigmund Jähn

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#11 Post by julian67 »

Enqueue and Play in MPlayer

Only the GUI version of mplayer supports -enqueue, but fortunately the non-gui version will load a playlist so it's possible to have a custom action which creates a playlist of all selected files and then opens mplayer and plays them in sequence. This works fine for one file or many:

Image

command:

Code: Select all

ls -w 1 %F >/tmp/mplist && mplayer -playlist /tmp/mplist
MPlayer opens with window decoration but not the gmplayer controls so you can move the mplayer window around and resize it in the normal way (and it keeps aspect ratio on resize unlike gmplayer) and control it with the usual keyboard commands or OSD menu.

MPlayer play 30 second sample of each file:

same as above, using a different playlist name and with a start position of 120 seconds (opening credits/titles are not very interesting, don't let you check subtitles and alternative audio streams and anyway those FBI warnings are way too scary). Plays for 30 seconds and then moves to next item in playlist.

Code: Select all

ls -w 1 %F >/tmp/mpvlist && mplayer -ss 120 -endpos 30 -playlist /tmp/mpvlist
Last edited by julian67 on 2010-02-21 00:17, edited 1 time in total.
Wisdom from my inbox: "do not mock at your pottenocy"

mephjones
Posts: 99
Joined: 2010-02-16 02:30
Location: Los Angeles, USA

Re: Post Your Thunar Custom Actions Here

#12 Post by mephjones »

I use this one to TeX files to PDF because pdftex doesn't handle my figures correctly:

Code: Select all

xterm -e 'TEXMFHOME=~/.local/share/texmf tex `basename %N .tex` && dvipdf `basename %N .tex` && rm -f `basename %N .tex`.log `basename %N .tex`.dvi'
The TEXMFHOME assignment should be changed or removed, of course. Running in xterm allows me to edit in a terminal window if there is an error.

Also, I use this for converting my scans to Djvu format:

Code: Select all

for i in %F; do c44 $i; done
I use for loops to do actions on several files when a command only works on one file at a time.

User avatar
ComputerBob
Posts: 1181
Joined: 2007-11-30 04:49
Location: The Mountains of the Sunshine State
Been thanked: 1 time

Re: Post Your Thunar Custom Actions Here

#13 Post by ComputerBob »

ComputerBob - Making Geek-Speak Chic (TM)
ComputerBob.com - Nearly 6,000 Posts and 23 Million Views
My Massive Stroke
Help! (off-topic)
_________________
Your Life Matters

mephjones
Posts: 99
Joined: 2010-02-16 02:30
Location: Los Angeles, USA

Re: Post Your Thunar Custom Actions Here

#14 Post by mephjones »

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'

nabilalk
Posts: 1
Joined: 2010-02-20 22:56

Re: Post Your Thunar Custom Actions Here

#15 Post by nabilalk »

julian67 wrote:Mount and unmount ISO, BIN, IMG, MDF disk images:

This requires fuseiso and that the user is a member of the fuse group.
@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:

sir fer
Posts: 923
Joined: 2008-09-10 18:49
Location: Auckland

Re: Post Your Thunar Custom Actions Here

#16 Post 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

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#17 Post 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!
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#18 Post 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
Wisdom from my inbox: "do not mock at your pottenocy"

User avatar
bugsbunny
Posts: 5354
Joined: 2008-07-06 17:04
Been thanked: 1 time

Re: Post Your Thunar Custom Actions Here

#19 Post 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

User avatar
julian67
Posts: 4633
Joined: 2007-04-06 14:39
Location: Just hanging around
Been thanked: 7 times

Re: Post Your Thunar Custom Actions Here

#20 Post 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?
Wisdom from my inbox: "do not mock at your pottenocy"

Post Reply