Get Your Default KDE and GNOME Menus in Line
by David D. Scribner

Although the User Manuals for the KDE and GNOME GUI environments include instructions on modifying the user's menus, changes made by the user are "personal" in that the settings are kept in the user's home directory (such as ~/.kde or ~./gnome for example) and have no affect on the default settings installed for new users in their home directories when invoking the environment for the first time.

However, when enabling the KDE and GNOME environments on Linux systems for users, one of the many tasks a system administrator must do is configure the "master", or default menus that a new user will have available to them when using the GUI environments for the first time.

For an example of some of the changes that you may wish to put in place, several of the default menu selections when running a stock installation are meant to be used only by root or administrative users. Having these selections appear in the menu tree is non-essential and perhaps even undesirable for many users without admin permissions. You may also find menu selections that are missing icons, placed in an incorrect submenu location or have applications that lack a menu selection entirely.

This article attempts to cover the tasks of customizing such default menu installations. As customizing the menus result in changes to the default installed files, back up any files/directories to cover that all important anatomical area before proceeding with any modifications!

Menu Basics

Both GNOME and KDE menu selections are represented by text files within directories (menu subfolders). These files contain the configuration variables for a selection which include Name and Comment, which Icon to use, and whether the selection is a submenu or application (Type). If the selection is an application, the file will also include the Exec variable, which is the command string that executes the application. Other variables exist for terminal settings, etc., but it is the first four mentioned that relate directly to the presentation of the menu selections.

Menu selections for global inclusion in the KDE or GNOME menu trees are kept in respective default directories, a shared base of directories and files that both packages will merge with their global menus, and personal user directories for any configuration changes to the menu particular to that user.

The environment's default directories and menu selections in a stock Red Hat 7.1 installation with GNOME 1.4 and KDE 2.1 for example are usually found in /usr/share/, with the shared, or common directory in /etc/X11/. The default base directory locations may vary from distribution and version, but the general locations are as follows:

Default Menu Directories
  Global Menus
  KDE /usr/share/applnk/
  GNOME /usr/share/gnome/apps/
  Common /etc/X11/applnk/
  Personal Menus
  KDE ~/.kde/share/applnk/
  GNOME ~/.gnome/apps/

For example, you may have a submenu titled Internet in both your KDE and GNOME menus. You might keep menu selections for KDE-specific Internet applications in /usr/share/applnk/Internet, selections for GNOME-specific Internet applications in /usr/share/gnome/apps/Internet, and selections for those Internet applications that are independent from any particular environment could be kept in /etc/X11/applnk/Internet. When viewing the Internet submenu in GNOME or KDE, those selections kept in the common directory /etc/X11/applnk/Internet will be merged with the environment-specific selections, enabling users of either environment to utilize these applications.

Menu Selection Files

Menu selection filenames have a suffix of .desktop, and with a prefix usually named after the item's title it's a fairly easy task to determine which file corresponds to which menu selection. Although the naming convention of a file might not be to your liking, some filenames may be listed in other configuration files, package databases, etc. and therefore should not be renamed haphazardly. However, files you create in addition to the base installation can usually be named according to whichever convention you like.

You may find two other variables listed in your menu <selection>.desktop files, Terminal and MultipleArgs. These variables or course signify if the application needs a terminal window, or includes multiple arguments in the command string. If you are creating menu selections from scratch take note of them, but they don't affect the display of the selection in the menu.

An example .desktop file for X-Chat (xchat.desktop), a popular graphic IRC client, would look similar to:

[Desktop Entry]
Comment=IRC Client

Submenu Files

Along with the *.desktop files, another file common to both KDE and GNOME is the .directory file. This file is used to signify the directory as a submenu, and is comprised of the Nameof the submenu, a Comment, the Icon to appear in the menu and specifies the Type to be a directory. You may find the other two other variables mentioned above, Terminal and MultipleArgs, in your submenu's .directory files, which should be set to false. If you have created a directory in the common /etc/X11/applnk location so that it appears as a submenu in both GNOME or KDE, it should contain a .directory file along with any *.desktop files for your menu selections.

For example, let's say that you've created the directory in /etc/X11/applnk/Internet so that items in this directory will appear in both the GNOME and KDE Internet submenus for your users. Your .directory file may look similar to the following:

[Desktop Entry]
Comment=Internet Applications Menu

Menu Selection Ordering in GNOME

Another file used by GNOME, and included in the menu directories is .order. This file, as its name implies, specifies the ordering of selections as they are to appear in the menu, and is comprised of a list of those selection's (or submenu) filenames. KDE does not include this ability at this time as all items appear alphabetically, and therefore does not use the file. If you chose to group or place certain selections together in your GNOME Internet submenu, keeping email clients, browsers and IRC clients together for example, a sampling of your .order file for the submenu might look something like this:


If you have a submenu directory in /usr/share/gnome/apps, and an identically named submenu directory in /etc/X11/applnk, you only need to include an .order file in the GNOME default directory that lists the combined selections. If two .order files are used, each with their respective list of selection files in that directory, those in /etc/X11/apps will be placed after the GNOME default selections.

Putting It All Together

By configuring your menu selections in these directories, you'll be able to place them in the submenus desired, and with the settings, wording and comments of your choosing.

One of the tasks you may find in configuring your menus is editing the Name and Comment fields in the menu selection files for consistency. Linux is a professional OS, and the tools packaged with most distributions are inarguably top-notch. However, just as they were developed by a varied group of programmers from around the world, the name and comment "style conventions" displayed in the GUI menus are often just as varied. Some comments may be displayed as sentences, some by a repeat of the name, some may even have no comments at all.

With a little editing your menu selections will be presented with a consistent format convention, and the display to users (or prospective clients) picks up just bit more professionalism with the cleaner appearance and continuity.

In a stock installation, even if you've chosen your default language, you will also notice that Name and Comment variables are listed in numerous other languages within the menu selection's .desktop file. Any of the languages not used on your network or system can have the respective line removed to save space and decrease load-time. This isn't necessary, of course, but many files can be decreased to a fraction of their original size. When you consider the files are usually only 2K, it's not that much of a decrease and may be inconsequential. But then again, the number of *.desktop files on your system that have multi-language variables can be quite high. The *.desktop files aren't limited to menu selections only, and a system with both the KDE and GNOME environments can have several hundred to well over a thousand of these files. On a system tight with resources every byte saved or decrease in load-time counts! Often, the .directory and .order files will also have multi-language variable listings as well. If you're trimming bytes you can include these files too, and may even consider a shell or Perl script to weed out the unused foreign language Name and Comment lines.

Along with the placement and contents of the files, keep in mind that you can restrict the display of menu selections to certain users or groups by altering the attributes of the files. The default permissions of 0644 on most menu selections enable the display of the item to all users. Change the owner or permissions of the file to suit your administrative requirements, preventing the display of selections, or even branches of menus to those not in need. Even though the selections might appear in the .order file used by GNOME, they will of course be passed over if the permissions don't apply to a particular user.

This comes in handy for applications that only root or particular group or department can use. Of course, this won't stop someone from bringing up a shell or run-menu and invoking the command, so more steps should be taken (if not already) for applications restricted to select individuals or groups. Streamlined menus are also easier to navigate, and "out of sight, out of mind" helps keep the "I wonder what this does?" accidents to a minimum when dealing with users new to the system.

Menu Configuration Tips

A few pointers to keep in mind when configuring your KDE and GNOME menus are:

Hopefully this article has helped you get your default KDE and GNOME menus in line for your new user setups. A clean and custom-structured menu system for your new users is only part of the equation however, as many companies also like to have customized desktops installed for their new users as well. I'll cover that issue in my next article, Get Your Default KDE and GNOME Desktops in Line. I hope to see you there!