Go to main content

Oracle® Solaris 11.3 Desktop Administrator's Guide

Exit Print View

Updated: March 2018
 
 

Merging Menus

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.

Merging User and System Menus

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.


Note - Older specifications did not include the type attribute and simply require the location of the menu file to be merged as the content of the <MergeFile> element. As a result, you might still see a location specified in the contents of <MergeFile>, even when type="parent".

    The menu merging is performed as follows:

  1. The children of the root <Menu> element in the merged menu file are substituted for the <MergeFile> element in the base menu file.


    Note - "Merged menu file" refers to the next applications.menu in the $XDG_CONFIG_DIRS/menus directory.
  2. 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>