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:
CODE
[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
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:
CODE
<?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>
<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:
CODE
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
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:
CODE
application/x-mswinurl
- I created /usr/share/mime-info/my.mime:
CODE
application/x-mswinurl
ext: url URL
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) :
CODE
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.
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:
CODE
#!/bin/bash
url="$(tr -d '\r' <"$1" | sed -n 's/^URL=//p')"
exec gnome-open "$url"
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.
