Gnome-menus
lastmod 2026-02-18created 2026-02-182 edits
gnome-menus is a library that implements freedesktop.org's Desktop Menu Specification, and generates and manages the application menu structure of the GNOME desktop environment.
Overview
It reads .desktop files and .menu XML files to build an application menu tree sorted into categories. The GNOME Shell app grid and other menu-based launchers use this library to display the list of installed apps.
How it works
- Reads the menu structure (category hierarchy) from
.menuXML files. - Matches apps to categories based on the
Categories=field of.desktopfiles. - Provides the sorted menu tree to applications.
Related files
| Path | Description |
| | XML files that define the menu structure |
| | Category (directory) names and icon definitions |
| | Desktop entries for individual apps |
.menu file example
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN"
"http://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd">
<Menu>
<Name>Applications</Name>
<Directory>X-GNOME-Menu-Applications.directory</Directory>
<Menu>
<Name>Accessories</Name>
<Directory>Utility.directory</Directory>
<Include>
<And>
<Category>Utility</Category>
<Not><Category>System</Category></Not>
</And>
</Include>
</Menu>
<Menu>
<Name>Graphics</Name>
<Directory>Graphics.directory</Directory>
<Include>
<Category>Graphics</Category>
</Include>
</Menu>
</Menu>
.directory file example
[Desktop Entry]
Name=Accessories
Comment=Desktop accessories
Icon=applications-accessories
Type=Directory
Provided components
| Component | Description |
| | C library (GObject Introspection support) |
| | Accessible from Python and others through GI bindings |
Python usage example
import gi
gi.require_version('GMenu', '3.0')
from gi.repository import GMenu
tree = GMenu.Tree.new('gnome-applications.menu', GMenu.TreeFlags.NONE)
tree.load_sync()
root = tree.get_root_directory()
it = root.iter()
while True:
item_type = it.next()
if item_type == GMenu.TreeItemType.INVALID:
break
elif item_type == GMenu.TreeItemType.DIRECTORY:
directory = it.get_directory()
print(directory.get_name())
Related specifications
| Specification | Description |
| Standard defining menu structure and categories | |
| Standard for the |