|
|
You can create completely new window manager menus that you can call to the screen by pressing a mouse button or a key on the keyboard, or by selecting it from an existing menu. You can also modify the existing window manager menus (the Root and Window menus) to include additional menu items or submenus.
To create a new window manager menu, perform the following steps.
$HOME/.pmwmrc for individual changes
$HOME/.mwmrc for individual changes
or
key_event context f.menu menu_name
See ``Configuring window manager button bindings'' and ``Configuring window manager key bindings'' for more information on button and key bindings.
When you have finished, save and exit the configuration file.
The default operation of the window manager is largely controlled by a system-wide file, called system.pmwmrc if you are using pmwm mode or system.mwmrc if you are using mwm mode. This file's functions include defining the contents of the Root and Window menus and how menu functions are invoked. Individual users can also have a version of this file, located in their home directories, called .pmwmrc (for pmwm mode) or .mwmrc (for mwm mode). This file can be used to customize window manager menus for an individual user without affecting other users on the system.
Open one of the following files for editing:
The $HOME/.pmwmrc and $HOME/.mwmrc files do not exist by default. If a local configuration file does not already exist in your home directory, copy the appropriate system-wide window manager configuration file to $HOME and rename the file either .pmwmrc or .mwmrc.
See also:
The first section of the window manager configuration file defines the contents of the Root and Window menus. If you want to create a new widow manager menu, add the menu definition to the end of this section.
A menu definition starts with the Menu
section type and a title for the section, designated by
the menu_name specification:
Menu menu_name
The menu_name specification is an internal reference and does not appear as the title of the menu. The string value that you assign to menu_name is often referenced elsewhere in the window manager configuration file. In particular, menu_name can be paired with a button action (in the button bindings section of the configuration file) so you can press a particular mouse button to display the menu. This concept is covered in greater detail in Step 4.
The following example shows the section type and title for the default Root menu:
Menu RootMenu
The syntax for defining items on a window manager menu
is very simple.
Each item is defined by a line that uses the following format:
{
label [mnemonic] [accelerator] function
}
The syntax for items on the Root menu is slightly different because mnemonics and accelerators are not available.
When creating menu options, note the following:
label can consist of a character string or a graphic representation (bitmap file). A character string must be compatible with the menu font that is used. Character strings must be typed precisely, using one of the following approaches:
If you are using a bitmap file instead of a character string, you need to tell the window manager the full path of the file. There are several methods for indicating a file's path:
Character | Function | Example |
---|---|---|
@ | the following string is a pathname | @/u/tammyr/bitmaps/root_weave |
~ | the user's home directory | ~/bitmaps/root_weave |
The first character in the label specification that matches the designated mnemonic is underlined on the menu. Note that the mnemonic specification is case sensitive.
If there is no matching character in label, no mnemonic is registered. The character must match a character in label exactly; the mnemonic cannot execute if any modifier (such as the <Shift> key) is pressed with the character.
This specification is optional, and is not available on the Root menu.
The accelerator specification has the following
syntax:
accelerator = Meta<key>funct_key
The accelerator sequence works whether or not the menu is displayed. Because of this, you should be careful not to use key actions that are already defined in the key bindings section of the window manager configuration file. Key bindings are discussed in greater detail in ``Configuring window manager key bindings''.
Because the key-action combination must be unique, accelerators use modifiers to provide more key-action combinations. Modifiers are keys that users must press simultaneously with the existing key event. All modifiers specified are exclusive; that is, only the specified modifiers can be present when the key event occurs.
The following list indicates the keys that can be used for modifiers:
modifier_name | Description |
---|---|
Ctrl | Control Key |
Shift | Shift Key |
Alt | Alt/Meta Key |
Meta | Meta/Alt Key |
Lock | Lock Key |
Mod1 | Modifier1 |
Mod2 | Modifier2 |
Mod3 | Modifier3 |
Mod4 | Modifier4 |
Mod5 | Modifier5 |
where function_name is one of the defined window manager functions, and function_args is a valid argument to the function.
There are a number of predefined window manager functions that you can use for the function_name clause. Each of the window manager functions has a name beginning with ``f.''. These functions define behavior, such as resizing windows (f.resize), moving a window (f.move), and iconifying a window (f.minimize). For a complete list of the available window manager functions and a description of their behavior, see ``Using window manager functions''.
There are several window manager functions that are particularly relevant to the task of creating menus. These functions include:
If a function_args contains any spaces, the argument must be contained within double quotations ``" "''.
"Restore" _R Alt<key>F5 f.normalize "Move" _M Alt<key>F7 f.move "Size" _S Alt<key>F8 f.resize "Minimize" _n Alt<key>F9 f.minimize "Lower" _L Alt<key>F3 f.lower "Raise" _a Alt Shift<key>F3 f.raise "Toggle Nail" _a Alt Shift<key>F2 f.nail "Hide" f.hide_panner
Before you can use your new menu, you must specify the method by which it can be accessed. You can attach the menu to an existing menu so it is available as a ``cascading'' or submenu. You can also configure the menu so a mouse button or key event displays the menu. These approaches are discussed here. You can also replace the default Window menu with your new menu, so it is automatically available by clicking on the window menu button. This approach is discussed in ``Changing the menu associated with the window menu button''.
For example, if you created a menu that you defined as ``GamesMenu'', and you want to access it from the Root menu, you would enter the following line within the Root menu definition section:
"Games Menu" f.menu "GamesMenu"
or
[modifier_keys]<Key>key_name context f.menu "menu_name"
For example, if you created a menu that you defined as ``GamesMenu'', and you want to access it by pressing the second mouse button on the Root window, enter the following line within the button binding section of the window manager configuration file:
<Btn2Down> root f.menu "GamesMenu"You can also use the f.post_wmenu function if you want to post the currently defined Window menu with a mouse button or key event. This function automatically displays the menu that is defined by the window manager windowMenu resource. If you intend to configure your new menu so it functions as the Window menu, use the f.post_wmenu function.
For detailed information on the button and key binding sections, see ``Configuring window manager button bindings'', and ``Configuring window manager key bindings''.
After you have added your new menu information to either the local window manager configuration file ($HOME/.pmwmrc or $HOME/.mwmrc) or the system-wide file (/usr/lib/X11/system.pmwmrc or system.mwmrc), you must restart the window manager before your changes can take effect and your new menu can be displayed.
Restart the window manager
by selecting the Restart Window Manager option
on the Root menu.
The Root menu is accessed by pressing
and holding mouse button 1 anywhere on the
Desktop background or,
if the Desktop is not running, in the Root window.
After the window manager restarts,
you can use your new menu.