The Best Without X
The Linux keyboard is fully customizable (could you doubt it?) and can be tailored for smart text-only usage. The idea is to reduce context-switch time to get more performance out of your multitasking brain. This is the basic idea behind virtual consoles.
Here are some suggestions for improving your keyboard. I will describe some of the useful changes to make, and then give the appropriate lines for the loadkeys program to effect the change.
Caps_Lock: Why have a “Caps Lock” key near the “a” key? When caps lock was useful to write silly BASIC programs they put it far from alphabetic keys; now that it is not so useful, they turned it to a trap for your little finger. Just get rid of it and turn it into a Control key.
alt-CapsLock will still yield CapsLock keycode 58 = Control control keycode 58 = Control
Control: The Control key on the bottom-left corner is a duplicate of the one we put by the “a”. You can turn it into Last_Console and thus have a fast editor/compiler context switch. Moreover, this makes your wrist useful in typing. Last_Console switches to the previous console you visited, and is one of the several exotic capabilities of the Linux keyboard.
keycode 29 = Last_Console
The Numeric Keypad Unless you're used to desktop calculators, the numeric keypad is too far in the right to be useful in typing digits, and can be turned to a console-switch scratchpad: hitting Alt-F8 takes a whole hand, and Alt-F1 isn't easy, either, at least on keyboards with the function keys at the top. Similarly, X-Windows users can configure the keypad as a map to their virtual desktop, provided that the Num_Lock key is left alone: xmodmap can't differentiate a non-Num_Locked keypad from the arrow keys. The “0” key then is suitable to be another Last_Console, useful if you didn't get rid of Caps_Lock.
keycode 29 = Last_Console # KP_0 keycode 79 = Console_1 # KP_1 keycode 80 = Console_2 # KP_2 keycode 81 = Console_3 # KP_3 keycode 75 = Console_4 # KP_4 keycode 76 = Console_5 # KP_5 keycode 77 = Console_6 # KP_6 keycode 71 = Console_7 # KP_7 keycode 72 = Console_8 # KP_8 keycode 73 = Console_9 # KP_9 keycode 98 = Console_10 # KP_Divide keycode 55 = Console_11 # KP_Multiply keycode 96 = Console_12 # KP_Enter keycode 78 = Console_13 # KP_Add keycode 74 = Console_14 # KP_Subtract
Home and End It can be useful to configure Home as Control -a and End as Control-e. This works with bash, tcsh and Emacs, without any other fiddling.
keycode 102 = Control_a keycode 107 = Control_e
Escape: If you are used to Sparc2s, old PCs, or the old faithful Apple II you'll enjoy putting the Esc key near the “1”. This change forces you to reposition the backtick/tilde pair as well. The exact change made here may not work on your keyboard, you'd better check your keycodes with showkeys.
keycode 41 = Escape # Escape alt keycode 1 = Meta_Escape # recycle grave/asciitilde near the Enter key keycode 43 = grave # asciitilde control keycode 41 = nul alt keycode 41 = Meta_grave
Backslash: The backslash/bar pair should be near “Z”, where the default keyboard configuration puts a duplicate of less/greater.
keycode 86 = backslash bar control keycode 43 = Control_backslash alt keycode 43 = Meta_backslash
The modifications listed above work with my keyboard. Check your actual keycodes using showkeys before applying these changes. showkeys is part of the kbd package. If you're a real typist, you can make something really useful out of the twelve function keys. Read the keytables(5) man page to probe further. For more information on how to modify the keyboard, see Kernel Korner in Linux Journal #14.
“Why should I use the numeric keypad to switch between 15 consoles when I only have 6?” I hear you say. Linux can handle a s many as 63 virtual console, and 6 (or whatever else) is only the number of “login prompts” configured in your system. Actually, consoles are dynamically created and destroyed during your system's lifetime.
The different login: prompts are spawned by the init process, which knows what to do by reading the file /etc/inittab; this very file specifies where getty should be invoked. You can play with inittab even if you don't completely understand it: to open more (or fewer) than 6 consoles for login, you can simply duplicate (or remove) lines. You must be careful, however, about the first field in the line—it is a unique “key” for the line, and it must be exactly two letters long.
My choice for console login sessions above 9 is cA, cB and so on, with the first nine entries c1 through c9.
A more interesting, and memory-saving, approach to your Linux session is to spawn only one or two gettys using /etc/inittab, and dynamically allocate other as you need them. There are a number of ways to spawn a new console:
gpm-root: This tool can spawn a new getty on the lowest-numbered free console in your system: just press control-mouse to wake the program, then press the mouse button again on the correct menu entry, and you will soon be presented with a newly-created login: prompt—it's that easy. When you log out from that console, everything is cleaned up automatically. This way of spawning consoles has the advantage that the /etc/utmp file is kept up to date, and thus the who command tells you the truth.
open: The tiny open utility spawns a new console and executes a program in it. You can use loadkeys to create a hot key which invokes open. Thus a single keypress (or meta-key) can log you in. This approach doesn't update the utmp database and works only when the hotkey is fed to a shell prompt.
spawn_console: The daemon spawn_console is part of the kbd package. It creates a console in response to a signal sent by the kernel in response to a Spawn_Console keysym. This approach works even if there isn't a shell to get your key, and doesn't update the utmp database.
Editorial Advisory Panel
Thank you to our 2014 Editorial Advisors!
- Jeff Parent
- Brad Baillio
- Nick Baronian
- Steve Case
- Chadalavada Kalyana
- Caleb Cullen
- Keir Davis
- Michael Eager
- Nick Faltys
- Dennis Frey
- Philip Jacob
- Jay Kruizenga
- Steve Marquez
- Dave McAllister
- Craig Oda
- Mike Roberts
- Chris Stark
- Patrick Swartz
- David Lynch
- Alicia Gibb
- Thomas Quinlan
- Carson McDonald
- Kristen Shoemaker
- Charnell Luchich
- James Walker
- Victor Gregorio
- Hari Boukis
- Brian Conner
- David Lane