Post Your Thunar Custom Actions Here

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

Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-15 23:34

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
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby bodiless » 2010-02-16 11:44

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
bodiless
 
Posts: 263
Joined: 2007-01-24 14:38
Location: Greece

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-16 15:32

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: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-16 16:03

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: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-16 16:15

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
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby bodiless » 2010-02-16 18:34

So basically you could point thunar to whatever script you like. Cool :-)
User avatar
bodiless
 
Posts: 263
Joined: 2007-01-24 14:38
Location: Greece

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-16 22:11

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
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby dbbolton » 2010-02-16 22:41

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
dbbolton
 
Posts: 2133
Joined: 2007-06-20 08:17
Location: Iapetus

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-17 18:14

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
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby gnutonian » 2010-02-17 19:48

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
gnutonian
 
Posts: 71
Joined: 2009-12-28 18:51
Location: France

Re: Post Your Thunar Custom Actions Here

Postby julian67 » 2010-02-18 01:12

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"
User avatar
julian67
 
Posts: 4648
Joined: 2007-04-06 14:39
Location: Just hanging around

Re: Post Your Thunar Custom Actions Here

Postby mephjones » 2010-02-18 23:53

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.
mephjones
 
Posts: 99
Joined: 2010-02-16 02:30
Location: Los Angeles, USA

Re: Post Your Thunar Custom Actions Here

Postby ComputerBob » 2010-02-19 05:25

ComputerBob - Making Geek-Speak Chic (TM)
ComputerBob.com
My New Ministry
User avatar
ComputerBob
 
Posts: 1189
Joined: 2007-11-30 04:49
Location: The Beautiful Sunshine State

Re: Post Your Thunar Custom Actions Here

Postby mephjones » 2010-02-19 08:05

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'
mephjones
 
Posts: 99
Joined: 2010-02-16 02:30
Location: Los Angeles, USA

Re: Post Your Thunar Custom Actions Here

Postby nabilalk » 2010-02-20 22:59

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:
nabilalk
 
Posts: 1
Joined: 2010-02-20 22:56

Next

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable