Consistent Keyboard Configuration
First, the kernel's keyboard translation tables will be redefined. Since these tables are not used directly by the X Window System, use one of the virtual consoles, not a window manager. Log in as root or use su. Different distributions of Linux may load the translation tables in different ways. To determine which keyboard translation table is in use, type:
# find /etc -type f | xargs grep loadkeys
You should see output something like:
/etc/init.d/boot: loadkeys \ /usr/lib/kbd/keytables/us.mapwhich would indicate that the U.S. translation table is in use.
Assuming the U.S. translation table is in use, enter the following commands to make a copy of it:
# cd /usr/lib/kbd/keytables # cp us.map custom.map
The format of keyboard table files is given in keytables(5).
Now edit custom.map using any text editor. Find the following lines:
keycode 14 = Delete Delete alt keycode 14 = Meta_Delete
These lines specify that when keynumber 14 is pressed (the BACKSPACE key), send a DELETE to the system, and when ALT-BACKSPACE is pressed, send a Meta_DELETE. To find out the keynumber of any key, use the showkey command.
To make the BACKSPACE key conform to the design decisions, change these lines to read:
keycode 14 = BackSpace BackSpace alt keycode 14 = Meta_BackSpace
However, a delete key is also needed, so replace the following line:
keycode 111 = Removewith these two lines:
keycode 111 = Delete Delete alt keycode 111 = Meta_DeleteKeynumber 111 is the DELETE key on the editing keypad, just below the INSERT key.
Now, to swap Caps_Lock with the left CTRL key, redefine keycodes 29 and 58 as follows:
keycode 29 = Caps_Lock # Left Control key. keycode 58 = Control # Caps Lock key.
Configuring the numeric keypad presents a special challenge. In us.map, several of the keys transmit the same escape sequences as an editing key. This makes it impossible, for example, for a program to distinguish between the PAGE UP key on the editing keypad and the 9/Pg Up key on the numeric keypad. Furthermore, the NUM LOCK, /, *, - and + keys do not even transmit escape sequences.
To alleviate these problems, the virtual console's numeric keypad will be configured somewhat like a VT100 numeric keypad. Since xterm already emulates a VT102, this will save work by making the virtual consoles more compatible with xterm. Note that this technique could cause incompatibilities with software programs that expect the keys to behave as defined by us.map. If this becomes a problem, the keys can always be switched back.
To be able to configure the keys of the numeric keypad independently, they will have to be changed into function keys. Since the kernel supports up to 246 function keys, F1 through F246, this is not a problem. Redefine the following keycodes as shown:
keycode 55 = F112 # Numeric keypad *. keycode 69 = F110 # NumLock. keycode 71 = F107 # Numeric keypad 7. keycode 72 = F108 # Numeric keypad 8. keycode 73 = F109 # Numeric keypad 9. keycode 74 = F113 # Numeric keypad -. keycode 75 = F104 # Numeric keypad 4. keycode 76 = F105 # Numeric keypad 5. keycode 77 = F106 # Numeric keypad 6. keycode 78 = F114 # Numeric keypad +. keycode 79 = F101 # Numeric keypad 1. keycode 80 = F102 # Numeric keypad 2. keycode 81 = F103 # Numeric keypad 3. keycode 82 = F100 # Numeric keypad 0. keycode 83 = F116 # Numeric keypad .. keycode 96 = F115 # Numeric keypad Enter. keycode 98 = F111 # Numeric keypad /.
Furthermore, it is necessary to define the escape sequences that these keys transmit, so add these lines to the end of the file:
string F100 = "\\033Op" string F101 = "\\033Oq" string F102 = "\\033Or" string F103 = "\\033Os" string F104 = "\\033Ot" string F105 = "\\033Ou" string F106 = "\\033Ov" string F107 = "\\033Ow" string F108 = "\\033Ox" string F109 = "\\033Oy" string F110 = "\\033OP" string F111 = "\\033Oo" string F112 = "\\033Oj" string F113 = "\\033Om" string F114 = "\\033Ok" string F115 = "\\033OM" string F116 = "\\033On""\\033" is the octal representation of ESCAPE. These are the same escape sequences that will be transmitted by these keys when running xterm, after following the remaining steps.
Although function keys F6 through F12 are compatible with xterm, F1 through F5 are not. To fix this, add these lines:
string F1 = "\\033[11~" string F2 = "\\033[12~" string F3 = "\\033[13~" string F4 = "\\033[14~" string F5 = "\\033[15~"
It is recommended that the following keycodes be defined so the keysyms (the names following the equals signs) will match the keycaps. However, this will not change the escape sequences transmitted, since these keysyms are only synonyms for the original keysyms:
keycode 102 = Home # Was Find. keycode 104 = PageUp # Was Prior. keycode 107 = Enc # Was Select. keycode 109 = PageDown # Was Next.One very nice feature is to be able to hold down the ALT key while using the arrow keys to pan within Emacs. Since ALT-Left and ALT-Right were previously used to switch virtual consoles, those functions will be remapped to CTRL-Left and CTRL-Right.
Change these two lines as shown:
# Ctrl-Left (was Alt) control keycode 105 = Decr_Console # Ctrl-Right (was Alt) control keycode 106 = Incr_Console
And add the following lines:
alt keycode 103 = F117 # Left Alt-Up Arrow altgr keycode 103 = F117 # Right Alt-Up Arrow alt keycode 105 = F120 # Left Alt-Left Arrow altgr keycode 105 = F120 # Right Alt-Left Arrow alt keycode 106 = F119 # Left Alt-Right Arrow altgr keycode 106 = F119 # Right Alt-Right Arrow alt keycode 108 = F118 # Left Alt-Down Arrow altgr keycode 108 = F118 # Right Alt-Down Arrow string F117 = "\\033\\033[A" # Alt-Up Arrow string F118 = "\\033\\033[B" # Alt-Down Arrow string F119 = "\\033\\033[C" # Alt-Right Arrow string F120 = "\\033\\033[D" # Alt-Left ArrowNote ALT-arrow transmits an ESCAPE followed by the normal escape sequence for the arrow key.
Of course, CTRL-ALT-DELETE will reboot Linux, but what if the user is finished for the day and wants a quick shutdown? To make CTRL-ALT-H-END shut down Linux, add the following lines:
# Numeric keypad End control alt keycode 79 = KeyboardSignal control altgr keycode 79 = KeyboardSignal # Editing keypad End control alt keycode 107 = KeyboardSignal control altgr keycode 107 = KeyboardSignal
Then save the file, and edit /etc/inittab. Add or edit the following lines as shown:
# Action on special keypress (CTRL-ALT-END). kb::kbrequest:/sbin/shutdown -h nowSave the file, and everything is ready to be tested. Type:
# loadkeys custom.mapand try the new keys. DELETE should act as BACKSPACE did before. Caps Lock has been switched with the left CTRL key. Exit all programs, then try CTRL-ALT-END. After shutdown, use the hardware reset button to reboot.
If the keyboard passed these basic tests, us.map can be replaced with custom.map. Regular users may encounter errors when running loadkeys, because it requires read access to /dev/console. Furthermore, different users using different maps could cause confusion. Therefore, it is suggested the new keymap be permanently installed on the system by root.
Warning: If these installation instructions are not followed correctly, it is possible to place the keyboard in an unusable state, forcing the user to reboot from the installation floppies. Please take any necessary precautions before proceeding.
To install custom.map permanently, edit /etc/init.d/boot, or whichever boot script contains the loadkeys command, and add the following line to the top of the file:
Then replace the loadkeys command with:
if [ -f $custom_keys ] # If custom keys exist, then # then load them. loadkeys $custom_keys else # Else use the regular keys. loadkeys /usr/lib/kbd/keytables/us.map fiThis way, if custom.map somehow gets deleted, the keyboard will still work. Run this script to make sure it is correct. If it works, the new keymap will be automatically activated at the next system boot.
|Designing Electronics with Linux||May 22, 2013|
|Dynamic DNS—an Object Lesson in Problem Solving||May 21, 2013|
|Using Salt Stack and Vagrant for Drupal Development||May 20, 2013|
|Making Linux and Android Get Along (It's Not as Hard as It Sounds)||May 16, 2013|
|Drupal Is a Framework: Why Everyone Needs to Understand This||May 15, 2013|
|Home, My Backup Data Center||May 13, 2013|
- Linux Systems Administrator
- Senior Perl Developer
- Technical Support Rep
- New Products
- UX Designer
- Designing Electronics with Linux
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- seo services in india
3 hours 52 min ago
- For KDE install kio-mtp
3 hours 53 min ago
- Evernote is much more...
5 hours 53 min ago
- Reply to comment | Linux Journal
14 hours 38 min ago
- Dynamic DNS
15 hours 12 min ago
- Reply to comment | Linux Journal
16 hours 11 min ago
- Reply to comment | Linux Journal
17 hours 1 min ago
- Not free anymore
21 hours 3 min ago
1 day 50 min ago
- Reply to comment | Linux Journal
1 day 58 min ago
Enter to Win an Adafruit Pi Cobbler Breakout Kit for Raspberry Pi
It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Pi Cobbler Breakout Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- 5-21-13, Prototyping Pi Plate Kit: Philip Kirby
- Next winner announced on 5-27-13!
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?