xmodmap(X) X Version 11 (11 July 1990) xmodmap(X)
NAME
xmodmap - modifies keymaps in X
SYNOPSIS
xmodmap [-options ...] [filename]
DESCRIPTION
The xmodmap utility edits and displays the keyboard modifier
map and keymap table that client applications use to convert
event keycodes into keysyms. You usually run xmodmap from
your session start-up script to configure the keyboard
according to your personal tastes.
OPTIONS
-display display
Specifies the host and display.
-help
Prints a brief description of the command-line options
on the standard error. This also happens whenever you
specify an unsupported option.
-grammar
Prints a help message on the standard error that
describes the expression grammar used in files and with
-e expressions.
-verbose
Prints logging information as xmodmap parses its input.
-quiet
Turns off the verbose logging. This is the default.
-n Displays what xmodmap would do if you requested it to
change the mappings. This option does not actually
change the mappings; it works like make does when you
specify make -n.
-e expression
Executes an expression. You can specify any number of
expressions from the command line.
-pm Prints the current modifier map on the standard output.
-pk Prints the current keymap table on the standard output.
-pp Prints the current pointer map on the standard output.
- Specifies the standard input as the input file.
The filename specifies a file containing xmodmap expressions
to execute. This file is usually resides in your home
Page 1 (printed 7/3/90)
xmodmap(X) X Version 11 (11 July 1990) xmodmap(X)
directory with a name like .xmodmaprc.
EXPRESSION GRAMMAR
The xmodmap utility reads a list of expressions and parses
them all before attempting to execute any of them. This way
you can refer to keysyms that are being redefined without
having to worry as much about name conflicts.
Allowable expressions include:
keycode NUMBER = KEYSYMNAME ...
Assigns a list of keysyms to the indicated keycode
(which you can specify in decimal, hex, or octal and can
determine by running the xev program in the examples
directory). Usually only one keysym is assigned to a
given code.
keysym KEYSYMNAME = KEYSYMNAME ...
Looks up the KEYSYMNAME on the left side to find its
current keycode and replaces the line with the
appropriate keycode expression.
Note that if you have the same keysym bound to multiple
keys, this might not work.
clear MODIFIERNAME
Removes all entries in the modifier map for the given
modifier, where 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 any keys that
were bound to the shift lock modifier.
add MODIFIERNAME = KEYSYMNAME ...
Adds the given keysyms to the indicated modifier map.
The keysym names are evaluated after all input
expressions are read to make it easy to write
expressions to swap keys (see "Examples" below).
remove MODIFIERNAME = KEYSYMNAME ...
Removes the given keysyms from the indicated modifier
map. Unlike add, the keysym names are evaluated as the
line is read in. This allows you to remove keys from a
modifier without having to worry about whether or not
they have been reassigned.
pointer = default
Sets the pointer map back to its default settings
(button 1 generates a code of 1, button 2 generates a
code of 2, and so on).
pointer = NUMBER ...
Page 2 (printed 7/3/90)
xmodmap(X) X Version 11 (11 July 1990) xmodmap(X)
Sets the pointer map to contain the indicated button
codes. The list always starts with the first physical
button.
EXAMPLES
If you want to change the binding of a modifier key, you
must also remove it from the appropriate modifier map. In
the following examples, comment lines begin with an
exclamation mark (!).
Most mice are designed so you press the first button with
your right index finger. People who are left-handed
frequently find that it is more comfortable to reverse the
button codes so that they can press the primary button with
their left index finger. This could be done on a three-
button pointer as follows:
% xmodmap -e "pointer = 3 2 1"
Many editor applications support the notion of Meta keys
(similar to Control keys except that you hold down the Meta
key instead of the Control key). However, some servers do not
have a Meta keysym in the default keymap table, so you may
have to add one.
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
just need the keycode and don't require the keysym 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) won't notice any change.
% keysym Multi_key = Multi_key Meta_L
One of the more convenient ways to use xmodmap is to set the
keyboard's "rubout" key to generate an alternate keysym.
This frequently involves exchanging Backspace with Delete.
If you set the ttyModes resource in xterm as well, all
terminal emulator windows use the same key for erasing
characters:
% xmodmap -e "keysym BackSpace = Delete"
% echo "XTerm*ttyModes: erase ^?" | xrdb -merge
Some keyboards do not automatically generate less than and
greater than characters when you shift the comma and period
keys. You can remedy this with xmodmap by resetting the
bindings for the comma and period with the following
scripts:
Page 3 (printed 7/3/90)
xmodmap(X) X Version 11 (11 July 1990) xmodmap(X)
!
! make shift-, be < and shift-. be >
!
keysym comma = comma less
keysym period = period greater
One of the more irritating differences between keyboards is
the location of the Control and Shift Lock keys. You can
use xmodmap to swap these two keys as follows:
!
! 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
You can use the keycode command for assigning the same
keysym to multiple keycodes. Although you cannot port this
method, you can use it to write scripts that can reset the
keyboard to a known state. The following script sets the
backspace key to generate Delete (as shown above), flushes
all existing CapsLock bindings, makes the CapsLock key a
control key, makes F5 generate Escape, and makes Break/Reset
a shift lock.
!
! On the HP, the following keycodes have
! key caps as listed:
!
! 101 Backspace
! 55 Caps
! 14 Ctrl
! 15 Break/Reset
! 86 Stop
! 89 F5
!
keycode 101 = Delete
keycode 55 = Control_R
clear Lock
add Control = Control_R
keycode 89 = Escape
keycode 15 = Caps_Lock
add Lock = Caps_Lock
ENVIRONMENT
DISPLAY
Page 4 (printed 7/3/90)
xmodmap(X) X Version 11 (11 July 1990) xmodmap(X)
Gets the default host and display number.
LIMITATIONS
Every time a keycode expression is evaluated, the server
generates a MappingNotify event on every client. This can
cause some thrashing. All of the changes should be batched
together and done at once. Clients that receive keyboard
input and ignore MappingNotify events do not notice any
changes made to keyboard mappings.
xmodmap does not generate add and remove expressions
automatically whenever a keycode that is already bound to a
modifier is changed.
SEE ALSO
X(X)
COPYRIGHT
Copyright 1988, Massachusetts Institute of Technology.
Copyright 1987 Sun Microsystems, Inc.
See X(X) for a full statement of rights and permissions.
AUTHOR
Jim Fulton, MIT X Consortium, rewritten from an original by
David Rosenthal of Sun Microsystems.
Page 5 (printed 7/3/90)