By default, user menu configuration files take precedence over system menu configuration files of the same name. For example, if an applications.menu file is present in the user's $XDG_CONFIG_HOME/menus directory, then that file will be used instead of the system applications.menu file to configure the Applications menu for that user. This replacement might result in the user not having access to all the menu items they would expect. To avoid this situation, a menu configuration file can specify that it should be merged with other menu configuration files, rather than replacing them. This process is described in the following sections.
Often, a user only wants to add or delete menu items in addition to the standard system menu. To support these changes, you should use the <MergeFile> element with the attribute type="parent" within the user's applications.menu file.
The <MergeFile> element enables a menu to be merged with the contents of the user's menu file. When you specify the element's type attribute as "parent", the contents of the <MergeFile> element are ignored. The next applications.menu file in the $XDG_CONFIG_DIRS/menus directory is used for merging.
The menu merging is performed as follows:
The children of the root <Menu> element in the merged menu file are substituted for the <MergeFile> element in the base menu file.
All child <Menu> elements with the same name are consolidated into a single <Menu> element by appending all child elements of each <Menu> element with the same name into the last occurrence of the menu element.
The following example shows a user menu file explicitly merging the system menu file.
<!DOCTYPE Menu PUBLIC "-//freedesktop//DTD Menu 1.0//EN" "https://www.freedesktop.org/standards/menu-spec/menu-1.0.dtd"> <Menu> <Name>Applications</Name> <MergeFile type="parent">/etc/xdg/menus/applications.menu</MergeFile> <Menu> <Name>Accessibility</Name> <Exclude> <Filename>dasher.desktop</Filename> </Exclude> </Menu> </Menu>