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.
- Run Smeg (install it first, perhaps) and create your menus.
- Examine the files:
- Move the files from ~/.config/menus to a system-wide accessible directory, for example /opt/mymenu, so you get /opt/mymenu/config/menus
- 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.
- 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
- 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!