theYinYeti Posted October 5, 2007 Report Share Posted October 5, 2007 In my project, I work with a team of windows users, but I use Linux. And we use (and have to use) so-called shortcut files, that is URL (to web) and LNK (to filesystem) files. Although the LNK format is quite obscure (and I wouldn't be able to create one by script), I am able to read those shortcut files with bash scripts, and thus in theory open them with gnome-open. BUT... I tried and associated my urlHandler.sh script to the .URL and .url extensions, as well as to the application/x-mswinurl mime type: - I created /usr/local/share/applications/urlHandler.desktop: [Desktop Entry] Encoding=UTF-8 Name=MS URL Handler Comment=Microsoft URL file handler Exec=/home/yves/bin/urlHandler.sh %u Icon=mozilla-firefox Terminal=false Type=Application MimeType=application/x-mswinurl; StartupNotify=false - I ran update-mime-database, thus generating the following /usr/share/mime/application/x-mswinurl.xml file: <?xml version="1.0" encoding="utf-8"?> <mime-type xmlns="http://www.freedesktop.org/standards/shared-mime-info" type="application/x-mswinurl"> <!--Created automatically by update-mime-database. DO NOT EDIT!--> </mime-type> - I created /usr/share/application-registry/my.applications: urlHandler.sh command=/home/yves/bin/urlHandler.sh name=MS URL Handler can_open_multiple_files=false expects_uris=true requires_terminal=false supported_uri_schemes=file,http,ftp mime_types=application/x-mswinurl - I created /usr/share/mime-info/my.keys: application/x-mswinurl - I created /usr/share/mime-info/my.mime: application/x-mswinurl ext: url URL This was all done with gathered info from "random" mime related packages and some info from the web. There should be a GUI hiding all this but I found none on the system, and this is such a basic requirement! In windows since WIN95 !!! (or is it Win3?) :-( Well, the result is not what I expected: - <my URL file> -> right click -> properties -> open with... : says "MS URL Handler" and shows firefox icon. That's OK. - <my URL file> -> double click -> (translated from French) : Impossible to open <my URL file> The name of the file "<my URL file>" indicates a file of type "resource locator". The content of this file indicates a file of type "application/x-mswinurl". Opening this file may prove to be a security risk to your system. Don't open this file unless you created it yourself or received it from a trusted source. To open this file, rename it with an appropriate extension for "application/x-mswinurl", then open it normally. Else use the Open with menu to select a particular application for this file. As if that were not bad enough, I had similar messages on non-windows-specific files ("ini" files, "txt" files...). My script does work on the same files. Nautilus is the problem-here. Here's the script by the way: #!/bin/bash url="$(tr -d '\r' <"$1" | sed -n 's/^URL=//p')" exec gnome-open "$url" I CAN'T STAND the system coming in my way like that :-( I'm mad with it :-( That's one reason, among others, why I don't use Windows. How can they imagine I'll browse the filesystem and rename each and every file of this type, whereas Linux should pay no strict attention to file extensions? Not even speaking of the loss for windows users (imagine if I renamed all shortcuts...). Sorry for the rant, I'm litterally angry at Gnome on this topic, and I'm going to abandon it if there's not a solution. I'm not going to live with this. Never. Yves. Quote Link to comment Share on other sites More sharing options...
Greg2 Posted October 5, 2007 Report Share Posted October 5, 2007 If you use KDE, you can use lnkforward. It's in the kdeaddons package, but I've never used it. You 'may' be able to incorporate it into Gnome? See: lnkforward Quote Link to comment Share on other sites More sharing options...
ianw1974 Posted October 5, 2007 Report Share Posted October 5, 2007 Maybe you can set the default application type for this file so that when you double-click it, it uses the app that you want it to. This is what I do with other apps, so I expect it can be done the same, since you're using right click from the menu to open it, so you can go into the properties of the file, and set up the default app to handle this file. Quote Link to comment Share on other sites More sharing options...
scoonma Posted October 5, 2007 Report Share Posted October 5, 2007 [...] url="$(tr -d '\r' <"$1" | sed -n 's/^URL=//p')" exec gnome-open "$url" Don't you mean > exec gnome-open $url ? Quote Link to comment Share on other sites More sharing options...
theYinYeti Posted October 8, 2007 Author Report Share Posted October 8, 2007 See: lnkforward That's indeed an interesting command, and I'm confident it can be used with Gnome too. However, the problem is with Nautilus "security measures", not with my script. Maybe Nautilus is into some kind of "secure mode" due to the fact that the files are stored on a Samba share, not a local partition... This is what I do with other apps, so I expect it can be done the same, since you're using right click from the menu to open it, so you can go into the properties of the file, and set up the default app to handle this file. That's what I did in the first place, but I had the forementionned error message; that's why I tried to make my script somehow more "official" by declaring it all over the system... to no avail. I'll try again, though. Maybe the combination of the two can make it. Don't you mean > exec gnome-open $url ? No, the quotes around "$url" are meant just like that, so that the whole $url is seen as a single argument even if the url contains spaces. Yves. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.