[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Commands Reference, Volume 6

xmodmap Command

Purpose

Modifies keymaps in the X Server.

Syntax

xmodmap-display Display ] [  -e  Expression ] [  -grammar -help ] [ -n] [  -pk ] [  -pke ] [  -pm ] [  -pp ] [  -quiet -verbose ] [ FileName ]

Description

The xmodmap command edits and displays the keyboard modifier map and keymap table that client applications use to convert event keycodes into key symbols. It is usually run from the session startup script to configure the keyboard according to the personal tastes of the user.

Every time a keycode expression is evaluated, the server generates a MappingNotify event on every client. All of the changes should be batched together and done at one time. Clients that receive keyboard input and ignore MappingNotify events will not notice any changes made to keyboard mappings.

The FileName parameter specifies a file containing the xmodmap command expressions to be run. This file is usually kept in the home directory of the user with a name like .xmodmaprc. If no file is specified, input is taken from stdin.

The xmodmap command program reads a list of expressions and parses them all before attempting to run any of them. This makes it possible to refer to key symbols that are being naturally redefined without having to worry as much about name conflicts.

add The key symbol names are evaluated as the line is read. This permits you to remove keys from a modifier without worrying about whether they were reassigned.
add ModifierName = KeySymbolName... Adds the given key symbols to the indicated modifier map. The key symbol names are evaluated after all input expressions are read to make it easy to write expressions to swap keys.
clear ModifierName Removes all entries in the modifier map for the given modifier, where the valid names are Shift, Lock, Control, Mod1, Mod2, Mod3, Mod4, and Mod5 (case does not matter in modifier names, although it does matter for all other names). For example, clear Lock removes all keys bound to the shift lock modifier.
keycode Number = KeySymbolName... Assigns the list of key symbols to the indicated keycode (which can be specified in decimal, hex, or octal and be determined by running the xev program in the /usr/lpp/X11/Xamples/demos directory). Usually only one key symbol is assigned to a given code.
keysym KeySymbolName = KeySymbolName... The KeySymbolName on the left hand side is translated into matching keycodes used to perform the corresponding set of keycode expressions. The list of keysym names can be found in the keysym database /usr/lib/X11/XKeysymDB or the header file X11/keysymdef.h (without the XK_ prefix). Note that if the same keysym is bound to multiple keys, the expression is run for each matching keycode.
pointer = default Sets the pointer map back to its default settings (such as, button 1 generates a code of 1, button 2 generates a 2, and so forth).
pointer = Button1 Button2 Button3... Sets the pointer map to contain the indicated button codes. The list always starts with the first physical button.
remove ModifierName = KeySymbolName... Removes all keys containing the given keysyms from the indicated modifier map. Unlike add, the keysym names are evaluated as the line is read in. This allows for the removal of keys from a modifier without having to worry about whether or not they have been reassigned.

Lines that begin with an ! (exclamation point) are taken as comments.

If you want to change the binding of a modifier key, you must also remove it from the appropriate modifier map.

Flags

-display Display Specifies the host and display to use.
-e Expression Specifies an expression to be run. You can specify any number of expressions from the command line.
-grammar Prints a help message describing the expression grammar used in files and with the -e Expressions flag prints to standard error.
-help Prints a brief description of the command line arguments to standard error. This is done whenever an unhandled argument is given to the xmodmap command.
-n Indicates that the xmodmap command should not change the mappings, but should display what it would do when given this flag.
-pk Indicates that the current keymap table should print on the standard output.
-pke Indicates that the current keymap table should be printed on the standard output in the form of expressions that can be fed back to xmodmap. This flag is specific to X11R5.
-pm Indicates that the current modifier map should print on the standard output.
-pp Indicates that the current pointer map should print on the standard output.
-quiet Turns off the verbose logging. This is the default.
-verbose Indicates that the xmodmap command should print logging information as it parses its input.

Examples

  1. The following command reverses the button codes that get generated so that the primary button is pressed using the index finger of the left hand on a 3 button pointer:

    xmodmap -e "pointer = 1 2 3 4 5"
  2. The following command attaches meta to the multi-language key (sometimes labeled Compose Character). It also takes advantage of the fact that applications that need a Meta key simply need to get the keycode and do not require the key symbol to be in the first column of the keymap table. This means that applications that are looking for a Multi_key (including the default modifier map) will not notice any change.

    keysym Multi_key = Multi_key Meta_L
  3. To automatically generate less than and greater than characters when the comma and period keys are shifted, reset the bindings for the comma and period with the following scripts:

    !
    ! make shift-, be < and shift-. be >
    !
    keysym comma = comma less
    keysym period = period greater
  4. To swap the location of the Control and Shift Lock keys, use the following script:

    !
    ! Swap Caps_Lock and Control_L
    !
    remove Lock = Caps_Lock
    remove Control = Control_L
    keysym Control_L = Caps_Lock
    keysym Caps_Lock = Control_L
    add Lock = Caps_Lock
    add Control = Control_L

Related Information

The X command.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]