Penguin
Annotated edit history of xmodmap(1) version 2, including all changes. View license author blame.
Rev Author # Line
1 JohnMcPherson 1 !!NAME
2 xmodmap - utility for modifying keymaps and pointer button mappings in X
3
4 !!SYNOPSIS
5 __xmodmap__ [[-options ...] [[filename]
6
7 !!DESCRIPTION
8
9
10 The ''xmodmap'' program is used to edit and display the keyboard ''modifier map'' and ''keymap table'' that are used by client applications to convert event keycodes into keysyms. It is usually run from the user's session startup script to configure the keyboard according to personal tastes.
11
12 !!OPTIONS
13
14
15 The following options may be used with ''xmodmap'':
16 ;__-display ''display''__ : This option specifies the host and display to use.
17 ;__-help__ : This option indicates that a brief description of the command line arguments should be printed on the standard error channel. This will be done whenever an unhandled argument is given to ''xmodmap.''
18 ;__-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.
19 ;__-verbose__ : This option indicates that ''xmodmap'' should print logging information as it parses its input.
20 ;__-quiet__ : This option turns off the verbose logging. This is the default.
21 ;__-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.
2 JohnMcPherson 22 ;__-e ''expression''__ : This option specifies an expression to be executed. Any number of expressions may be specified from the command line.
1 JohnMcPherson 23 ;__-pm__ : This option indicates that the current modifier map should be printed on the standard output.
24 ;__-pk__ : This option indicates that the current keymap table should be printed on the standard output.
25 ;__-pke__ : This option 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''.
26 ;__-pp__ : This option indicates that the current pointer map should be printed on the standard output.
27 ;__-__ : A lone dash means that the standard input should be used as the input file.
28
29 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 ''.xmodmaprc''.
30
31 !!EXPRESSION GRAMMAR
32
33
34 The ''xmodmap'' program reads a list of expressions and parses them all before attempting to execute any of them. This makes it possible to refer to keysyms that are being redefined in a natural way without having to worry as much about name conflicts.
35 ;__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. Up to eight keysyms may be attached to a key, however the last four are not used in any major X server implementation. The first keysym is used when no modifier key is pressed in conjunction with this key, the second with Shift, the third when the Mode_Switch key is used with this key and the fourth when both the Mode_Switch and Shift keys are used.
36 ;__keycode any = ''KEYSYMNAME ...''__ : If no existing key has the specified list of keysyms assigned to it, a spare key on the keyboard is selected and the keysyms are assigned to it. The list of keysyms may be specified in decimal, hex or octal.
37 ;__keysym ''KEYSYMNAME'' = ''KEYSYMNAME ...''__ : The ''KEYSYMNAME'' on the left hand side is translated into matching keycodes used to perform the corresponding set of __keycode__ expressions. The list of keysym names may be found in the header file ''<X11/keysymdef.h>'' (without the ''XK_'' prefix) or the keysym database ''__projectroot__/lib/X11/XKeysymDB''. Note that if the same keysym is bound to multiple keys, the expression is executed for each matching keycode.
38 ;__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.
39 ;__add ''MODIFIERNAME'' = ''KEYSYMNAME ...''__ : This adds all keys containing 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).
40 ;__remove ''MODIFIERNAME'' = ''KEYSYMNAME ...''__ : This 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 you to remove keys from a modifier without having to worry about whether or not they have been reassigned.
41 ;__pointer = default__ : This sets the pointer map back to its default settings (button 1 generates a code of 1, button 2 generates a 2, etc.).
42 ;__pointer = ''NUMBER ...''__ : This sets to pointer map to contain the indicated button codes. The list always starts with the first physical button.
43
44 Lines that begin with an exclamation point (!) are taken as comments.
45
46 If you want to change the binding of a modifier key, you must also remove it from the appropriate modifier map.
47
48
49 !!EXAMPLES
50
51
52 Many pointers are designed such that the first button is pressed using the index finger of the right hand. People who are left-handed frequently find that it is more comfortable to reverse the button codes that get generated so that the primary button is pressed using the index finger of the left hand. This could be done on a 3 button pointer as follows:
53 % xmodmap -e "pointer = 3 2 1"
54
55 Many applications support the notion of Meta keys (similar to Control keys except that Meta is held down instead of Control). However, some servers do not have a Meta keysym in the default keymap table, so one needs to be added by hand. The following command will attach 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 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.
56 % xmodmap -e "keysym Multi_key = Multi_key Meta_L"
57
58 Similarly, some keyboards have an Alt key but no Meta key. In that case the following may be useful:
59 % xmodmap -e "keysym Alt_L = Meta_L Alt_L"
60
61 One of the more simple, yet convenient, uses of ''xmodmap'' is to set the keyboard's "rubout" key to generate an alternate keysym. This frequently involves exchanging Backspace with Delete to be more comfortable to the user. If the ''ttyModes'' resource in ''xterm'' is set as well, all terminal emulator windows will use the same key for erasing characters:
62 % xmodmap -e "keysym !BackSpace = Delete"
63 % echo "XTerm*ttyModes: erase ^?" | xrdb -merge
64
65 Some keyboards do not automatically generate less than and greater than characters when the comma and period keys are shifted. This can be remedied with ''xmodmap'' by resetting the bindings for the comma and period with the following scripts:
66 !
67 ! make shift-, be < and shift-. be >
68 !
69 keysym comma = comma less
70 keysym period = period greater
71
72 One of the more irritating differences between keyboards is the location of the Control and Shift Lock keys. A common use of ''xmodmap'' is to swap these two keys as follows:
73 !
74 !
75 Swap Caps_Lock and Control_L !
76 remove Lock = Caps_Lock
77 remove Control = Control_L
78 keysym Control_L = Caps_Lock
79 keysym Caps_Lock = Control_L
80 add Lock = Caps_Lock
81 add Control = Control_L
82
83 The ''keycode'' command is useful for assigning the same keysym to multiple keycodes. Although unportable, it also makes it possible 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 caps lock bindings, makes the !CapsLock key be a control key, make F5 generate Escape, and makes Break/Reset be a shift lock.
84 !
85 ! On the HP, the following keycodes have key caps as listed:
86 !
87 ! 101 Backspace
88 ! 55 Caps
89 ! 14 Ctrl
90 ! 15 Break/Reset
91 ! 86 Stop
92 ! 89 F5
93 !
94 keycode 101 = Delete
95 keycode 55 = Control_R
96 clear Lock
97 add Control = Control_R
98 keycode 89 = Escape
99 keycode 15 = Caps_Lock
100 add Lock = Caps_Lock
101
102 !!ENVIRONMENT
103
104
105 ;__DISPLAY__ : to get default host and display number.
106
107 !!SEE ALSO
108 X(7x), xev(1), ''Xlib'' documentation on key and pointer events
109
110 !!BUGS
111
112
113 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.
114
115 ''Xmodmap'' should generate "add" and "remove" expressions automatically whenever a keycode that is already bound to a modifier is changed.
116
117 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.
118
119 !!AUTHOR
120 Jim Fulton, MIT X Consortium, rewritten from an earlier version by David Rosenthal of Sun Microsystems.
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.