Friday, August 18, 2006

Xmodmap on login.

I use xmodmap to change a few keybindings. This post describes how to get xmodmap to load your settings upon login.

Create ~/.xinitrc (or maybe ~/.xsession) with two lines: the first loads your xmodmap file; the second starts the windowmanager. Since I am using xfce4, my .xinitrc file looks like so.
/usr/bin/xmodmap ~/.xmodmaprc
exec /usr/bin/startxfce4
Exit. At the login screen change the "session" setting to "Default System Session" and log in.

Here is my .xmodmaprc file.
keycode 112 = 30

! Swap Caps_Lock and Control_L
! since my pinkie hurts.

remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

! bind the menu key to the right control key
! since my laptop does not have a right CTRL.

keycode 117 = Control_R
add Control = Control_R

! On the Compaq Presario 2800CA, the the following
! keycodes are listed for the special keys at the
! top of the keyboard.
!
! 163 i
! 158 envelope
! 154 magnifying glass
! 239 music note
! 174 - (volume down)
! 176 + (volume up)

keycode 174 = F18
keycode 176 = F19