Jump to content

How to cure Nautilus of its paranoid behaviour?


Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...