[Thunar-dev] Conditional "Open" command

mmassonnet at gmail.com mmassonnet at gmail.com
Sun Nov 4 19:33:55 CET 2007


On Sun, Nov 04, 2007 at 05:41:43PM +0100, Mathias Brodala wrote:
> Hi.
> 
> Imagine the following situation: you have two files in a directory, a video and
> a subtitle file for this video.
> 
> Now just calling, e. g. mplayer with these two files won’t do since it requires
> the "-sub" option to recognize the subtitle file.
> 
> Creating a custom action also doesn’t work since the custom command won’t be
> displayed as soon as both the video and subtitle file are selected. (Pattern:
> "*.ass;*.srt;*.ssa", for video and text files)
> 
> Any idea how I could accomplish this in Thunar? It would be great if Thunar
> could do all of this by itself and required me only to select the usual "Open"
> action.

Most probably, you have a b0rked mplayer.  Here it works just fine if I
open a video.avi file with Thunar that has on its side a file called
video.srt or video.sub.  It works also without problem with VLC and
Totem.

The desktop entry file I have for mplayer is not villain:
% cat mplayer-usercreated.desktop
[Desktop Entry]
Encoding=UTF-8
Type=Application
NoDisplay=true
Name=mplayer
Exec=mplayer
MimeType=video/x-msvideo;video/x-ms-wmv;video/quicktime;video/mpeg;application/x-flash-video


But if you need a quick solution for mplayer, use a wrapper script.
#!/bin/sh
test -f "${1%\.*}.srt" && exec mplayer -sub "${1%\.*}.srt" $*
test -f "${1%\.*}.sub" && exec mplayer -sub "${1%\.*}.sub" $*
exec mplayer $*

Put it inside ~/.local/bin/mplayer for instance, and make sure your PATH
starts with that path.

> Regards, Mathias

HTH,
Cheez!
Mike



More information about the Thunar-dev mailing list