Sunday, November 29, 2009

Transforming Caps Lock into the Super key

Crunchbang has a lot of great keyboard shortcuts configured by default, e.g. Super+W launches Firefox, Super+T launches the Terminal, and Super+F launches PCManFM, the greatest file manager ever.  I love the idea of using keyboard shortcuts to get stuff done faster but I think it is unfortunate that in Crunchbang they are paired with the Super key (a.k.a the "Windows" key).  There are still a few keyboards that don't have a Super key and on my Dell Inspiron 5100, it is located way out in the middle of nowhere above the Backspace key.

I have a few options to fix this, the most obvious being that I could go into my rc.xml file, which contains the key mappings, and change the paired key from Super to something else, like Ctrl, Shift, or Alt.  I was hesitant to do that for obvious reasons: I didn't want to lose the functionality currently provided by those keys.  So I decided to keep the keyboard shortcuts paired with Super but remap my Super key to Caps Lock to make it easier to get to.

Enter xmodmap.  Xmodmap is the Linux keyboard mapping tool and is probably part of every distribution.  Xmodmap is one of those tools that can do just about anything but it can be a little tricky to learn.  I started my quest with this fantastic tutorial, and ended up with a file called .Xmodmap in my home directory (i.e. /home/jizldrangs/.Xmodmap) that contained the following:

     keycode 66 = Super_L
     keycode 133 = Caps_Lock

According to the tutorial that should have worked, and it probably would have if I were trying to switch N and W, but as it turns out these utility keys, such as Super, Ctrl, Alt, and even Shift, require special steps because they are "modifiers".  To make a long story less long, here is what I ended up with in my .Xmodmap:

     clear lock
     add mod4 = Caps_Lock

After rebooting I have exactly what I wanted: Caps Lock is converted over to Super and doesn't turn on the Caps Lock or capitalize anything anymore.

No comments:

Post a Comment