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/applications.menu
    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
    XDG_DATA_HOME=/opt/mymenu/share
  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!

About these ads

14 Responses to “Create a custom GNOME menu”

  1. yourusername » Blog Archive » Create a system-wide, custom GNOME menu. Says:

    [...] read more | digg story [...]

  2. Ritesh Khadgaray Says:

    Hiya,

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

  3. Jeremy Says:

    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.

  4. shreevatsa Says:

    You can also use Sabayon, which is much simpler to use :-)
    (Is there any disadvantage to it?)

  5. automatthias Says:

    At the time of writing, I couldn’t get Sabayon to work. It was constantly crashing. Does it work now?

  6. shreevatsa Says:

    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?

  7. Christian Dannie Says:

    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.

  8. Wild Jackfield Chase « SwitchBuntu Says:

    [...] and one of them must have the Image module somewhere in there.  Yet even more hunting and I find that I may be able to use /etc/environment to hold the PYTHONPATH variable.  I tried and it [...]

  9. Ariszló Says:

    Is there a way to change the GNOME menu system-wide but leave the KDE menu alone?

  10. GNOME and frustration « The Lumber Room Says:

    [...] GNOME and frustration Filed under: Uncategorized — shreevatsa @ 14:40:13 +0000 There is no way of removing the “Shut down” menu — asked here. I asked here. [...]

  11. I'm frustrated too! Says:

    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…

  12. bupyipt Says:

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

  13. razuki Says:

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

  14. Share Menu with other users Says:

    [...] of the nice things about Linux is that developers don't change stuff just so it looks different: http://automatthias.wordpress.com/20…om-gnome-menu/ http://home.comcast.net/~3rdshift/ar…inux_tips.html [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

Join 474 other followers

%d bloggers like this: