6

I have two very similar .desktop launcher files that are to be used as internet shortcuts. When I double click on one file it opens properly in a webbrowser as I would like. When I double click on the other, it opens in a text editor which I do NOT like. How do I change this?

Good shortcut opens in browser:

[Desktop Entry]
Encoding=UTF-8
Name=Safari Books
Type=Link
URL=http://hdl.library.upenn.edu/1017/7026
Icon=text-html
Name[en_US]=Safari Books

Bad shortcut opens in text editor:

[Desktop Entry]
Encoding=UTF-8
Name=Learning Python
Type=Link
URL=http://proquestcombo.safaribooksonline.com/book/programming/python/9780596805395
Icon=text-html
Name[en_US]=Learning Python
5
  • @BiggJJ he means that the URL is downloaded but opens in gedit instead of a browser (since it is an XML file)
    – January
    Jul 11, 2013 at 19:59
  • compare thier file permissions with ls -l
    – j0h
    Jul 11, 2013 at 20:15
  • I have copied your second .desktop file and made the test, results: the first time I clicked it was opened in Firefox (good), now the second time (and the next...) it does open in GEdit. Not sure but this might actually be a bug. Try reporting it. Curiously Nautilus opens a dialog offering the possibility to cancel.
    – edwin
    Jul 11, 2013 at 20:27
  • Seriously, this is a bug in Nautilus in my opinion. This behavior is quite unexpected.
    – edwin
    Jul 11, 2013 at 20:38
  • thanks for feedback! I will look into reporting as a bug.
    – Selah
    Jul 15, 2013 at 19:18

1 Answer 1

6

I don't have a good solution, but I have a solution. You see, the desktop entry specification does not determine the viewer or mime type for a link. A link can be an image, a document, whatever, and the correct viewer will be chosen based on what the file is. And so it happens that this link opens with an editor (and not a browser). You have two options.

However, here is a little change that will result in the correct behavior, although it is ugly. Modify the desktop entry like this:

[Desktop Entry]
Encoding=UTF-8
Name=Learning Python
Type=Application
Exec=xdg-open http://proquestcombo.safaribooksonline.com/book/programming/python/9780596805395
Icon=text-html
MimeType=text/html
Name[en_US]=Learning Python

It will look the same, but it will be an application launcher. Just remember to set the permissions to execute in that case!

3
  • 3
    Instead of "Firefox", you can type "xdg-open", which will make your default browser open the link.
    – speter
    Jul 11, 2013 at 20:58
  • Yeah. But I still do not understand why the url opens in the editor.
    – January
    Jul 11, 2013 at 22:54
  • 2
    Don't forget to chmod +x the desktop file. That tripped me up. Must read instructions more carefully :)
    – Selah
    Jul 15, 2013 at 19:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .