Linux Menu – How to Create URL Link in Menu

gnomekdelinuxmenurhel

How can I create a menu item that points to a URL?

I've tried creating a mylink.desktop entry like this:

[Desktop Entry]
Encoding=UTF-8
Name=My Link Name
Icon=my-icon
Type=Link
Categories=Office;
URL=http://www.example.com/

then using xdg-desktop-menu install mylink.desktop should put this entry in the current user's menu. This does not work however. The file is copied into ~/.local/share/applications/ but the entry doesn't show up in the menu.

If I change Type to Application and define Exec instead of URL then it works. But I don't want to have menu entry for a local application. I want a default browser to launch on a specified address when the menu entry is selected.

How can I do that?

Also, by using this command: xdg-desktop-icon install mylink.desktop the result is as expected – a new link is created on the desktop. So why doesn't it work in the menu?

I tested this on RedHat Enterprise Linux 6 with KDE, but I would like to know how to do it in Gnome as well.

Best Answer

While reading up on stuff I stumbled uppon this question. That gave me an idea for a workaround:

[Desktop Entry]
Encoding=UTF-8
Name=My Link Name
Icon=my-icon
Type=Application
Categories=Office;
Exec=xdg-open http://www.example.com/

This does exactly what I need and is a local application, so I can use xdg-desktop-menu to install this entry without problems.

Related Question