Consistent Keyboard Configuration
Now start X as root. Change the directory to /etc/X11 and look at the file Xmodmap. Most likely, this file is empty, except for some comments. If not, rename it to Xmodmap.old, exit the window manager and restart X.
Starting with an empty Xmodmap is important, because when X comes up, it creates its keyboard modifier map and keymap table based on the kernel's current keyboard translation tables, which were just reconfigured. X then reads the Xmodmap file, which overrides the kernel. This could destroy some of the benefits of the work just completed on the kernel.
Since the kernel has already been reconfigured, the work of configuring X will be reduced by the work already done in creating custom.map. Specifically, DELETE and BACKSPACE will still transmit DELETE and BACKSPACE, because X got that information from the kernel.
Now enter the following command to replace Xmodmap with the current keymap table:
# xmodmap -pke > /etc/X11/Xmodmap
Edit Xmodmap. It appears similar to the file custom.map, but do not be misled. The keycodes are different. To find the keycode number for a given key, run xev from an xterm, put the mouse cursor inside the xev window, and press the key. Look for the key's “keycode” in the output. For more information, see xev(1) and xmodmap(1).
Finally, to switch the Caps Lock and the left CTRL key, add these lines to the end of the file:
! Recreate the Lock and Control modifier maps. clear Lock clear Control add Lock = Caps_Lock add Control = Control_L Control_R
To be able to configure keys on the numeric keypad, they must be given an appropriate keysym following the equals sign. Therefore, change the following lines as shown:
keycode 63 = KP_Multiply keycode 77 = KP_F1 keycode 79 = KP_7 keycode 80 = KP_8 keycode 81 = KP_9 keycode 82 = KP_Subtract keycode 83 = KP_4 keycode 84 = KP_5 keycode 85 = KP_6 keycode 86 = KP_Add keycode 87 = KP_1 keycode 88 = KP_2 keycode 89 = KP_3 keycode 90 = KP_0 keycode 91 = KP_Decimal keycode 108 = KP_Enter keycode 112 = KP_DivideKeycodes 99 and 105 are assigned to the keysyms Prior and Next, respectively. Just as was done in custom.map, change them to the following keysyms, which are functionally equivalent, but match the keycaps:
keycode 99 = Page_Up keycode 105 = Page_DownNow save the file, then type:
# xmodmap /etc/X11/Xmodmapto activate the new definitions. If your keyboard will not work at all, use CTRL-ALT-BACKSPACE to exit X. Then use a virtual console to fix the problem.
The xterm program receives keysyms from X and converts them into characters and into escape sequences. Since xterm emulates a VT102 terminal, it requires little configuration work.
Edit the /etc/X11/Xresources file, and add the following line:
XTerm*ttyModes: erase ^H
This automatically makes BACKSPACE (CTRL-H) delete characters to the left of the cursor. It is the same as if the user typed:
$ stty erase ^Hevery time an xterm was started. Also add this line:
XTerm*appkeypadDefault: trueThis will cause the keys of the numeric keypad to transmit their escape sequences instead of numbers, operators, etc. It is the same as if the user pressed CTRL--MiddleButton and selected “Enable Application Keypad” in every xterm window.
Unfortunately, Emacs normally resets the numeric keypad when it exits, so the keys no longer transmit escape sequences. To correct this behavior, the “rmkx” capability must be removed from the terminfo(5) database:
# cd /etc/terminfo/x # infocmp xterm > xterm.txt # emacs xterm.txt
Remove the “rmkx” entry, save the file, and exit. Then:
# tic xterm.txt # rm xterm.txtIt is also necessary to tell xterm what the ALT-Arrow keys transmit, and what the HOME and END editing keys transmit. (The default escape sequences that xterm uses for HOME and END are unconventional.) Type the first seven lines below. Then cut and paste the remaining lines from the xterm(1) man page, underneath the heading, “The default bindings in the VT102 window are.”
XTerm*VT100*translations:\\ Alt <KeyPress> Up:string(0x1b) string(0x1b) string("OA") Alt <KeyPress> Down:string(0x1b) string(0x1b) string("OB") \\n\\ Alt <KeyPress> Right:string(0x1b) string(0x1b) string("OC") \\n\\ Alt <KeyPress> Left:string(0x1b) string(0x1b) string("OD") \\n\\ <KeyPress> Home:string(0x1b) string("[1~") \\n\\ <KeyPress> End:string(0x1b) string("[4~") \\n\\ Shift <KeyPress> \ Prior:scroll-back(1,halfpage) \\n\\ Shift <KeyPress> \ Next:scroll-forw(1,halfpage) \\n\\ Shift <KeyPress> \ Select:select-cursor-start() \\n\\ Shift <KeyPress> select-cursor-end(PRIMARY, \ CUT_BUFFER0) \\n\\ Shift <KeyPress> Insert:insert-selection(PRIMARY,\ CUT_BUFFER0) \\n\\ ~Meta<KeyPress>:insert-seven-bit() \\n\\ Meta<KeyPress>:insert-eight-bit() \\n\\ !Ctrl <Btn1Down>:popup-menu(mainMenu) \\n\\ !Lock Ctrl <Btn1Down>:popup-menu(mainMenu) \\n\\ !Mod2 Ctrl <Btn1Down>:popup-menu(mainMenu) \\n\\ !Mod2 Lock Ctrl \ <Btn1Down>:popup-menu(mainMenu) \\n\\ ~Meta <Btn1Down>:select-start() \\n\\ ~Meta <Btn1Motion>:select-extend() \\n\\ !Ctrl <Btn2Down>:popup-menu(vtMenu) \\n\\ !Lock Ctrl <Btn2Down>:popup-menu(vtMenu) \\n\\ !Mod2 Ctrl <Btn2Down>:popup-menu(vtMenu) \\n\\ !Mod2 Lock Ctrl \ <Btn2Down>:popup-menu(vtMenu) \\n\\ ~Ctrl ~Meta <Btn2Down>:ignore() \\n\\ ~Ctrl ~Meta <Btn2Up>:insert-selection(PRIMARY, CUT_BUFFER0) \\n\\ !Ctrl <Btn3Down>:popup-menu(fontMenu) \\n\\ !Lock Ctrl <Btn3Down>:popup-menu(fontMenu) \\n\\ !Mod2 Ctrl <Btn3Down>:popup-menu(fontMenu) \\n\\ !Mod2 Lock Ctrl \ <Btn3Down>:popup-menu(fontMenu) \\n\\ ~Ctrl ~Meta <Btn3Down>:start-extend() \\n\\ ~Meta <Btn3Motion>:select-extend() \\n\\ <BtnUp>>>>>>>>:select-end(PRIMARY, CUT_BUFFER0) \\n\\ <BtnDown>:bell(0)Make sure each line ends exactly as shown, and there is not even a blank space after the last backslash on each line. Then change “Prior” to “Page_Up,” change “Next” to “Page_Down,” and change “Select” to “End” to match the keycaps.
ALT-Arrow transmits an ESCAPE (0x1b in hexadecimal) followed by the escape sequence for the arrow key, but ALT-<Keypress> sets the eighth bit of that key (examine the line that begins with “Meta<KeyPress>”). Also, the escape sequences for the ALT-arrow keys are not the same as were used in custom.map. For a full explanation of this file's format, see the RESOURCES heading under X(1). Save the file. Type:
# xrdb /etc/X11/Xresources
to activate the definitions. The BACKSPACE key should now work properly the next time an xterm is started.
- Ubuntu MATE, Not Just a Whim
- Nasdaq Selects Drupal 8
- Non-Linux FOSS: Screenshotting for Fun and Profit!
- Build Your Own Raspberry Pi Camera
- Secure Desktops with Qubes: Compartmentalization
- Canonical Ltd.'s Ubuntu Core
- An Introduction to Tabled Logic Programming with Picat
- The Peculiar Case of Email in the Cloud
- A New Mental Model for Computers and Networks
- Polishing the wegrep Wrapper Script