XMODMAP(1) — Unix Programmer’s Manual
NAME
xmodmap, xprkbd - keyboard modifier utilities for X
SYNOPSIS
xmodmap [-options ...] [filename] xprkbd [-display display]
DESCRIPTION
Xmodmap is a utility for displaying and altering the X keyboard modifier map and keysym table on the specified display and host. It is intended to be run from a user’s X startup script to setup the keyboard according to personal tastes.
With no arguments, xmodmap displays the current map.
Xprkbd prints on the standard output a table of the keycodes, the keysym code, and the keynames for the keyboard on the appropriate X server.
OPTIONS
Both programs accept the following option:
−display display
This option specifies the host and display to use; see X(1).
The xmodmap program also accepts:
−help This option indicates that a brief description of the command line arguments should be printed on the standard error. This will be done whenever an unhandled argument is given to xmodmap.
−grammar
This option indicates that a help message describing the expression grammar used in files and with -e expressions should be printed on the standard error.
−verbose
This option indicates that xmodmap should print logging information as it parses its input.
−quiet This option turns off the verbose logging. This is the default.
−n This option indicates that xmodmap should not change the mappings, but should display what it would do, like make(1) does when given this option.
−e expression
This option specifies an expression to be executed. Any number of expressions may be specified from the command line.
−p This option indicates that the current modifier map should be printed on the standard output.
− A lone dash means that the standard input should be used as the input file.
The filename specifies a file containing xmodmap expressions to be executed. This file is usually kept in the user’s home directory with a name like “.keymap.km”.
For compatibility with an older version, xmodmap also accepts the following obsolete single letter options:
-[SLC12345]
These options indicate that all current keys for the Shift, Lock, Control, or Mod modifier sets should be removed from the modifier map. These are equivalent to clear expressions.
-[slc] keysym
These options specify a keysym to be removed from the Shift, Lock, or Control modifier sets. These are equivalent to remove expressions.
+[slc12345] keysym
These options specify a keysym to be added to the Shift, Lock, or Control modifier sets. These are equivalent to add expressions.
EXPRESSION GRAMMAR
The xmodmap program reads a list of expressions and converts them into appropriate calls to the Xlib routines XChangeKeyboardMapping, XInsertModifiermapEntry and XDeleteModifiermapEntry. Allowable expressions include:
keycode NUMBER = KEYSYMNAME ...
The list of keysyms is assigned to the indicated keycode (which may be specified in decimal, hex or octal and can be determined by running the xev program in the examples directory). Usually only one keysym is assigned to a given code.
keysym KEYSYMNAME = KEYSYMNAME ...
The KEYSYMNAME on the left hand side is looked up to find its current keycode and the line is replaced with the appropriate keycode expression. Note that if you have the same keysym bound to multiple keys, this might not work.
clear MODIFIERNAME
This removes all entries in the modifier map for the given modifier, where valid name 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” will remove all any keys that were bound to the shift lock modifier.
add MODIFIERNAME = KEYSYMNAME ...
This 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 the EXAMPLES section).
remove MODIFIERNAME = KEYSYMNAME ...
This 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.
Lines that begin with an exclamation mark (!) 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.
EXAMPLES
To make the backspace key generate a delete instead, use
% xmodmap -e "keysym BackSpace = Delete"
To swap the left control and caps lock keys you could use:
!
! 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
As a more complicated example, the following is what the author uses:
!
! On the HP, the following keycodes have key caps as listed:
!
! 101 Backspace
! 55 Caps
! 14 Ctrl
! 15 Break/Reset
! 86 Stop
! 89 F5
!
! I prefer using “keycode” over “keysym” so that I can rerun the file to
! fix up my keyboard.
!
! This sets the backspace key to generate Delete, flushes all caps lock
! bindings, assigned a control key to what used to be the caps lock key,
! makes the F1 generate ESC, and makes the Break/Reset key be a shift lock.
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
to get default host and display number.
SEE ALSO
BUGS
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 will not notice any changes made to keyboard mappings.
Xmodmap should generate "add" and "remove" expressions automatically whenever a keycode that is already bound to a modifier is changed.
There should be a way to have the remove expression accept keycodes as well as keysyms for those times when you really mess up your mappings.
COPYRIGHT
Copyright 1988, Massachusetts Institute of Technology.
Copyright 1987 Sun Microsystems, Inc.
See X(1) for a full statement of rights and permissions.
AUTHOR
Jim Fulton, MIT X Consortium, rewritten from an original by David Rosenthal of Sun Microsystems
X Version 11 — 1 March 1988