
Fedora's application menus include many different programs from different packages. Fedora supports multiple desktop environments, including
GNOME,
KDE, and
Xfce, and each of these has a different menu structure, which may include or exclude certain proograms, such as the control panels for each environment. Each menu title and menu entry can be be presented in multiple languages. Furthermore, the menu layout has changed between Fedora releases, even though some of the packages have not changed. How does this all work?
The specifications for menu entries are collaboratively defined at freedesktop.org. Each Fedora RPM package that has application menu entries contains one or more .desktop files describing those menu entries. For example, the evolution package contains multiple .desktop files:
$ rpm -ql evolution | grep desktop
/usr/share/applications/redhat-evolution-calendar.desktop
/usr/share/applications/redhat-evolution-contacts.desktop
/usr/share/applications/redhat-evolution-mail.desktop
/usr/share/applications/redhat-evolution-tasks.desktop
/usr/share/applications/redhat-evolution-calendar.desktop
/usr/share/applications/redhat-evolution-contacts.desktop
/usr/share/applications/redhat-evolution-mail.desktop
/usr/share/applications/redhat-evolution-tasks.desktop
The first file, /usr/share/applications/redhat-evolution-calendar.desktop, contains the information necessary to display the Calendar menu entry (here I've removed some of the name and comment translations):
[Desktop Entry]
Name=Calendar
Name[es]=Calendario
Name[fi]=Kalenteri
Name[fr]=Calendrier
Comment=Manage your schedule using Evolution
Comment[es]=Planee sus actividades con Evolution
Comment[fi]=Hallitse kalenteriasi Evolutionilla
Comment[fr]=Gérer votre programme à l'aide d'Evolution
Exec=evolution --component=calendar
Icon=stock_calendar
Terminal=0
Type=Application
Encoding=UTF-8
Categories=X-Red-Hat-Base;X-Red-Hat-Base-Only;Office;Application;
StartupNotify=True
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=Evolution
X-GNOME-Bugzilla-Version=2.10
X-GNOME-Bugzilla-Component=Calendar
X-GNOME-Bugzilla-OtherBinaries=evolution-data-server-1.10;evolution-exchange-storage;evolution-alarm-notify;
As you can see, this file provides the name and comment (description) for this program in both a default presentation and language-specific versions (In this case, the default presentation is in English, but that is not always the case). Other lines in this file specify the command to be executed, the icon (which is looked up in the current theme, but could also be an icon file), whether the program should be run within a terminal, the character set encoding of the name and comment strings, the application categories, and whether this program supports the Startup Notify protocol (so that a "Starting Calendar" icon can be presented to the user).
The X-GNOME-Bugzilla- entries at the end of the file are an example of desktop-specific entries which will be ignored by other desktop environments (X- stands for experimental or non-standard, a tradition which stems from the X- headers used in e-mail messages).
The information in this file can be used to present a menu entry, panel icon, or desktop icon to the user. The location of the .desktop file controls the presentation, so making a desktop icon from this menu entry is accomplished simply by copying /usr/share/applications/redhat-evolution-calendar.desktop to ~/Desktop.
The arrangement of menu entries into menus is controlled by files in /etc/xdg/menus. These files are in an XML format defined at http://standards.freedesktop.org/menu-spec/latest/. These files specify how menus are to be built up by including and excluding various combinations of menu categories, directories containing .desktop files, and specific .desktop filenames. The individual .desktop files may also include OnlyShowIn and NotShowIn entries that specify in which desktop environment(s) the applications should or should not appear.
For example, in /etc/xdg/menus/applications.menu, there is markup for the Office menu:
<!-- Office -->
<Menu> <Name>Office</Name>
<Directory>Office.directory</Directory>
<Include>
<And>
<Category>Office</Category>
</And>
</Include>
</Menu> <!-- End Office -->
The Calendar menu entry from /usr/share/applications/redhat-evolution-calendar.desktop is picked up because it is marked as belonging to the Office category. The <And> tag requires a bit of explaination: content in the <And> tag is logically ANDed together. Since there is only one value in this example, it alone controls the content of this submenu. Here's another example which applies two criteria:
<!-- Accessories submenu -->
<Menu>
<Name>Accessories</Name>
<Directory>Accessories.directory</Directory>
<Include>
<And>
<Category>Utility</Category>
<Not>
<Category>System</Category>
</Not>
</And>
</Include>
</Menu> <!-- End Accessories -->
This specifies that the Accessories submenu should contain everything marked as being in the Utility category except for applications which are also marked as being part of the System category.