Create a custom GNOME menu

I had to create a customized GNOME menu for all users in the system. At first, the concept of .desktop files was a bit mysterious to me, as they represent more abstract way of dealing with the desktop menus. Then I found Smeg, the GNOME menu editor. I created a menu, but then I couldn’t find where Smeg has placed the files. Then I found the Desktop Menu Specification, which is implemented in GNOME 2.12. Reading it on, I learned also about the XDG Base Directory Specification, which helped me to find out, where does Smeg put created menu entries.

The idea was: create a Debian (Ubuntu, more precisely) package which places some files in the system. The expected result is a new menu visible for all users. I found out how to create a new menu which would contain my menu and include the original system menu. The problem was how to create a system-wide environmental variables. In Slackware, I would create a file in /etc/profile.d with appropriate entry. Unfortunately, Ubuntu does not have such directory. There is a file called /etc/environment that by default contains language settings. It can be used to set system wide environmental variables.

Finally, I created entries with Smeg, copied files to public readable directory and set two variables (XDG_CONFIG_HOME and XDG_DATA_HOME) to point at appropriate directories. Result: system wide menu contained in separate package. The only problem is to edit the /etc/environment file. I would prefer to do the task by only placing files, without any editing. With file editing, the package has to contain scripts that insert the entry on install, modify on package update and remove the entry on package delete. With files, the package manager does this task.

Ubuntu guys, please introduce the /etc/profile.d directory.

UPDATE: Since this post is becoming popular among people who search for how to create a custom menu, here’s a recipe for you. Please note that the current-user menu editing is trivial, Smeg does everything. This is about how to create a system-wide custom GNOME menu.

  1. Run Smeg (install it first, perhaps) and create your menus.
  2. Examine the files:
    1. ~/.config/menus/
    2. ~/.local/share/desktop-directories
    3. ~/.local/share/applications
  3. Move the files from ~/.config/menus to a system-wide accessible directory, for example /opt/mymenu, so you get /opt/mymenu/config/menus
  4. Move the files from ~/.local/share/applications and ~/.local/share/desktop-directories to a system-wide accessible directory, for example /opt/mymenu/share, so you get /opt/mymenu/share/desktop-applications and /opt/mymenu/share/applications.
  5. Set a system-wide environment variables. In Ubuntu, you can use /etc/environment for this. In Slackware, you can use /etc/profile. In Gentoo, you can place a new file in /etc/env.d (I like it the most: just place a file, is all). The file should set two environment variables:XDG_CONFIG_HOME=/opt/mymenu/config
  6. Restart the computer so the new environment variables start to be visible system-wide.

Those menus should appear in KDE as well.

If you like this HOWTO, please digg it!


Author: automatthias

You won't believe what a skeptic I am.

14 thoughts on “Create a custom GNOME menu”

  1. Hiya,

    Nice article. Is there a way to share desktop icons globally ?

  2. You are a life saver. I had everything setup for system wide based on the Menu Specification but, not all distributions follow the spec exaclty which, is were I ran into trouble. Setting those to env variables solved my problem.

  3. Sabayon was reasonably stable and only crashed once 😉 but it didn’t seem to do anything useful. I’m sorry for mentioning it; I had just begun to try it then.
    What I’m looking for is a way to remove the shutdown button from the GNOME menu for all users (they keep clicking Shut Down instead of Log Out by mistake)… and neither Sabayon nor the above steps (smeg is now called alacarte, BTW) help with that.
    Any ideas?

  4. shreevatsa: You should be able to remove their access to shutting down the system from the user preferences, then “Shut Down” won’t appear anymore.

  5. it seems to be, that the panel-shutdown-functionality is linked to the gdm behaviour. In order to “hide” the Shutdown-Button, just uncheck the checkbox “Show Actions menu” in the “Login Window Preferences” (Systen->Administration->Login Screen) et viola, the shutdown-button disappears…

  6. Занимаюсь дизайном и хочу попросить автора отправить шаьлончик на мой мыил) Готов заплатить…

  7. Hi,
    I work on red hat enterprise linux, and I there is no suchs files (~/.config/menus/, ~/.local/share/desktop-directories, ~/.local/share/applications ).
    But there is a directory named /etc/profile.d
    How can I customize Gnome menu ?

Comments are closed.