Making Caps Lock an Additional Control in XWindows

Background: I just built a new computer, and "upgraded" to Ubuntu 12.04. I've been a fan of Ubuntu for a long time (first Debian, then Ubuntu because of the faster / more predictable release cycle). But you can add me to the list of people unimpressed with the "Unity" desktop environment, and not terribly impressed by Gnome 3. Since I'm in the middle of an upgrade and learning about new features anyway, I figured I'd make the leap to a better window manager. I've settled on i3, which gives me a lot of power over how things are arranged. Of course it also means that I've got to configure a bunch of stuff the way I want it, more so than with the default Gnome/Unity/Metacity scheme. This potentially means some short-ish posts here about tweaks & tips for working with i3.

The first item of business is getting rid of Caps Lock. The example config in xmodmap(1) will swap your caps lock and control, which is definitely not what I want. The key to the left of the "A" (which happens to be labeled Caps Lock) should be treated the same as the left Control key. So I created ~/.xmodmap with the following contents:

!
! Make Caps_Lock an additional Control key
! (This is *DIFFERENT* than *swapping* Caps_Lock and Control, as described
! in the xmodmap(1) man page.)
!
keycode 66 = Control_L Control_L Control_L Control_L Control_L Control_L Control_L Control_L
clear lock
add Control = Control_L

Then, in your ~/.i3/config add:

exec_always xmodmap ~/.xmodmap

(Note that if you use the xmodmap commands provided in the xmodmap man page, then restarting i3 will toggle that key between Caps_Lock and Control, which is probably not what you want! It seems that you also lose the swap if you do things like run xev.)

Posted on 2012-05-11 by brian in linux .
Comments on this post are closed. If you have something to share, please send me email.