1

I'm trying to create a desktop file to any page but all of them open google. I'm using firefox in xubuntu 14.10.

#!/usr/bin/env xdg-open
[Desktop Entry]
Version=1.0
Type=Link
Icon[es]=gnome-panel-launcher
Name[es]=askubuntu
URL=http://askubuntu.com/
Name=askubuntu
Icon=gnome-panel-launcher
  • It might be simpler to use Type=Application & Exec=firefox "http://askubuntu.com"/ instead of Type=Link & URL=http://askubuntu.com/. When I last tried using link launchers all kinds of weird stuff occured (opened most of the links in Chromium, Firefox new windows all rest of the time, etc) – Wilf Mar 07 '15 at 21:10

2 Answers2

0

It might be simpler to use:

Type=Application
....
Exec=firefox "http://askubuntu.com"

instead of Type=Link & URL=https://askubuntu.com/. When I last tried using link launchers all kinds of weird stuff occured (opened most of the links in Chromium, Firefox new windows all rest of the time, etc)

An alternative to adding the #!/usr/bin/env xdg-open line to the top is to make the file executable using this command:

chmod +x "/PATH/TO/LAUNCHER.desktop"

or by making sure this is ticked in the file's properties (under 'permissions'):

Execute: Allow executing file as program

See also: Desktop launcher documentation?

Wilf
  • 30,194
  • 17
  • 108
  • 164
  • Type=Link is the correct way to make .desktop files which point to web sites. Using Type=Application may be a workaround for a misconfigured system or other bugs you encountered, but it's not the correct way to do it. Also, making the file executable is not an alternative to having a shebang and using the file as a shell script. They are different things and result in very different behavior. – dobey Mar 07 '15 at 21:51
0

The fact is, .desktop files are not scripts. You need to remove the #!/usr/bin/env xdg-open from the top of the file. You do not run them from a terminal either. If you want to open them from a terminal, you would run xdg-open askubuntu.desktop for example. You do need to ensure they are executable to open them from within Nautilus though, as it requires the executable bit to be able to use them as launchers, rather than opening them in the text editor.

dobey
  • 40,982
  • #!/usr/bin/env xdg-open used to work in most desktop environments until some years ago. For security reasons that has changed but you still find that line in some .desktop files. Like other lines starting with # it is just ignored. – Florian Diesch Mar 07 '15 at 21:33
  • It is ignored unless you try to run the file as a shell script from the terminal. My answer is correct. I don't understand why you would downvote it simply because you might disagree with the answer. – dobey Mar 07 '15 at 21:49