PDA

View Full Version : [preferably BASH] double-click file to automatically "open with" my script?



MaxIBoy
September 4th, 2008, 11:10 PM
I'm writing a BASH script to parse the .lnk files that pass for shortcuts on Windows filesystems. Ideally, I'd double-click a .lnk file, and the target will be opened with the default application (so double-clicking a shortcut to a program in the "desktop" folder of my Windows installation opens the program in WINE.)

How do I associate the .lnk file format with my script, and what code should I write in my script to receive whatever file it is supposed to open?

If this is more conveniently done in another language, let me know.

ghostdog74
September 5th, 2008, 02:25 AM
don't know if its want you want. see here (http://jesgue.homelinux.org/scripts/lnk2symlink)

mssever
September 5th, 2008, 03:13 AM
In Linux (or Gnome; I don't know about other environments), you associate mimetypes, not extensions. Check out xdg-open for your best bet to auto-open a file in the right application. You might be best off "converting" .lnk files to .desktop files. There are a number of examples in /usr/share/applications, and there's a spec on freedesktop.org.

cb951303
September 5th, 2008, 12:54 PM
right click any *.lnk file.
click properties.
go to "open with" tab.
click "add".
click "use a custom command".
voila!

mssever
September 5th, 2008, 05:56 PM
right click any *.lnk file.
click properties.
go to "open with" tab.
click "add".
click "use a custom command".
voila!
So How do you distinguish between a shortcut to an MP3 and a shortcut to an OOo document?

cb951303
September 5th, 2008, 06:20 PM
So How do you distinguish between a shortcut to an MP3 and a shortcut to an OOo document?

in this case that's the job of his/her shell script. there is no other way of doing it...

mssever
September 5th, 2008, 06:49 PM
That's clearer now. You didn't specify earlier that a custom shell (or other) script was required.

cb951303
September 6th, 2008, 01:21 AM
That's clearer now. You didn't specify earlier that a custom shell (or other) script was required.

OP did. he/she is talking about relating his/her shell script to *.lnk files

MaxIBoy
September 7th, 2008, 02:37 AM
So How do you distinguish between a shortcut to an MP3 and a shortcut to an OOo document?

/usr/bin/gnome-open.