! ===================[ Xmodmap                              ]===================
!
! -------------------( SYNOPSIS                             )-------------------
! This file is a global keyboard modifier map. On startup, X.org modifies the
! global keyboard table in accord with this file's specified instructions.
!
! -------------------( KEY IDENTIFIERS                      )-------------------
! Note that there is a hierarchy of low- to high-level abstraction for
! identification of keyboard keys. In order of increasingly high-level
! abstraction, this is:
!
! ~ Scancode. A scancode is the lowest-level identifier for a key. This is a
!   kernel-tier abstraction, and roughly corresponds to the raw, underlying
!   keyboard. This is an integer.
! ~ Keycodes. A keycode is the middle-level identifier for a key. This is a
!   X.org-tier abstraction, allowing X.org to abstract away raw, underlying
!   scancodes and unify the xmodmap interface. This is an integer.
! ~ Symbols. A symbol is the highest-level identifier for a key. This is, also,
!   an X.org-tier abstraction. As the name suggests, this is simply a string
!   representation of the keycode corresponding to this symbol.
!
! -------------------( KEY IDENTIFICATION                   )-------------------
! Keycodes may be identified, "on the fly," by execution of one of two
! applications: "showkey", if you are not in X.org but, rather, at a real
! console), or "xev", if you are not at a real console but, rather, in X.org.
! "showkey" should not be run from within X.org; similarly, "xev" should not be
! run from without X.org. (Technically, "showkey" may be run from within X.org.
! It tends, however, to give spurious output when doing so.)
!
! Occasionally, some keys will fail to have associate keycodes in the output
! from these applications. When this is the case, examine the system log for two
! lines resembling:
!
!   atkbd.c: Unknown key pressed (translated set 2, code 0xf1 on isa0060/serio0).
!   atkbd.c: Use 'setkeycodes e071 <keycode>' to make it known.
!
! Such lines suggest that, although this key has no keycode, it does have an
! associate scancode. In such cases, you may make a manual mapping from this
! scancode to the new keycode of your case. For details, see: 
!
!   http://wiki.archlinux.org/index.php/Map_scancodes_to_keycodes
!
! -------------------( FILE UPDATES                         )-------------------
! To update the current keyboard modifier map and table against changes made 
! to this file, run:
!
!   # Apply changes.
!   xmodmap /etc/X11/Xmodmap
!
!   # Check changes!
!   xmodmap -pm
!
! -------------------( FILE STRUCTURE                       )-------------------
! This file is, conventionally, a mapping of X.org key codes to X.org keysyms.
! Keycodes are uniquely integral identifiers X.org assigns to each physical key;
! keysyms are literal characters, symbols, or multimedia functions.
!
! This file is thus a hash mapping from input key to output action. Each such
! mapping resembles a line:
!
!   keycode ${X_KEYCODE} = ${X_KEYSYM}
!
! X.org lists all available keysyms at, typically:
! "/usr/include/X11/keysymdef.h". Examples follow:
!
!   # Assign the key corresponding to keycode 239 to output the literal 'e'.
!   keycode 239 = e
!
!   # Assign the key corresponding to keycode 239 to output the symbol '$'.
!   keycode 239 = $
!
!   # Assign the key corresponding to keycode 239 to output the action "mute
!   # audio."
!   keycode 239 = XF86AudioMute
!
! For more details, see "man xmodmap".
!
! -------------------( FILE USE                             )-------------------
! This file intends, principally, to remap keyboard modifier keys in such a way
! as to maximize ergonomic utility.
!
! To do this, two precepts stand apparent: that the less frequently typed
! modifier keys should be assigned to the weaker fingers, and that the more the
! stronger.
!
! Which are the weaker fingers? This is the simpler question, as it has one
! objective answer: in order of increasing strength, the pinky, the ring, the
! middle, the index, and the thumb.
!
! Which are the less frequently typed modifier keys? This is not a simple
! question, unfortunately; it's answers are necessarily subjective, based on
! the distribution of most frequently used applications and, of those
! applications, their most frequently typed modifier keys.
!
! The most frequently used applications are, as of March, 2009 for me: Emacs,
! vim, zsh, ncmpcpp, Links, and Firefox. 
!
! The most frequently typed modifier keys for Emacs are, in order of
! decreasing frequency: Shift, Ctrl, Meta, Super, Tab, and Escape. Most other
! applications, however, tend to neglect the Meta modifier key; so, for these,
! the most frequently typed modifier keys tend to be, in order of decreasing
! frequency: Shift, Ctrl, Super, Tab, Escape, and Meta.
!
! The happiest medium between these two probably places Meta at a lesser
! frequency than Super, but a higher frequency than Tab; so, we have compromise
! frequencies of: Shift, Ctrl, Super, Meta, Tab, and Escape.
!
! Note that some modifier keys for weaker fingers are nonetheless easier to type
! than those for stronger fingers. The Caps key, for example, is simpler to type
! than the lower Enter key. This suggests we produce a sorted list of all pinky
! and thumb-specific keys, from most ergonomic to least, and assign modifier and
! non-modifier keys using that.
!
! This suggests an Apple iBook-centric listing:
!
! ~ Left Apple.
! ~ Right Apple.
! ~ Caps.
! ~ Alt.
! ~ Left Shift.
! ~ Tab.
! ~ Enter.
! ~ Ctrl.
!
! -------------------( FILE ISSUES                          )-------------------
! By default, X.org disables auto-repeat for the Caps key. If you reassign this
! key to, for example, Backspace but do not explicitly enable its auto-repeat,
! then holding down the Caps key do nothing rather than iteratively backspace
! over characters. To correct this, run:
!
!   # Enable auto-repeat for the Caps key, where ${CAPS_KEYCODE} is that key's
!   # X.org keycode: typically, "66".
!   xset r ${CAPS_KEYCODE}
!
! Under some older systems (e.g., the Apple iBook), this command has no effect.
!clear Lock
!
!remove Control =   Control_L
!remove Mod1 =      Meta_L
!remove Mod4 =      Super_L
!remove Shift   =   Shift_L

!FIXME: Please note that what follows is the optimal modifier map for the
!Apple iBook, but is unlikely to be optimal for other keyboards. (The Linux
!Apple iBook keyboard implementation is rather broken, frankly. Given that,
!this is the best I can do; other makes, models, and vendors, however, should
!permit me to produce a substantially better layout.)

! Unfortunately, the Apple iBook's Caps and ISO_Level3_Shift (i.e., the lower
! right-hand "enter") keys cannot be bound to modifier keys. The latter seems
! to be aliased, by the low-level kernel, to the so-called "Level 3" modifier,
! <Alt-Gr>. (So, we assign both to frequently used non-modifier keys.)
!keysym Tab =       Shift_L
!keysym Caps_Lock = Tab
!keysym Shift_L =   Control_L
!keysym Super_L =   Meta_L
!keysym Meta_L =    Super_L 
!keysym Control_L = Escape
!keysym ISO_Level3_Shift = BackSpace
!
!add    Control =   Control_L Control_R
!add    Mod1 =      Meta_L Meta_R
!add    Mod4 =      Super_L Super_R
!add    Shift   =   Shift_L Shift_R
