7

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.

Fiktik
  • 221
  • 2
  • 7

2 Answers2

5

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.

Fiktik
  • 221
  • 2
  • 7
0

AFAIK, you need to create a Link.directory file in /usr/share/deskop-directory. And merge this directory into the proper menus [ by editing the /etc/xdg/applications.menu, I guess. Please check the exact menu file ]

SHW
  • 14,786
  • 14
  • 66
  • 101
  • You mean to create mylink.directory with the same contents as mylink.desktop above, but add it as a new menu directory? Would this really work? – Fiktik Apr 28 '11 at 08:57
  • no no. Not the mylink.directory but the Link.directory. [ here Link is value you write against the "Type" variable ] – SHW Apr 28 '11 at 09:09
  • OK, could you please be more specific? What should Link.directory contain? I suppose I could add it by invoking xdg-desktop-menu as well instead of manually editing /etc/xdg/menus/applications.menu, right? – Fiktik Apr 28 '11 at 10:45
  • http://satishwagh.blogspot.com/2010/05/adding-sub-menu-to-main-menu.html – SHW Apr 28 '11 at 11:19
  • this doesn't help me at all. I don't want to create any custom submenu... – Fiktik Apr 28 '11 at 11:23