Hacking your keyboard with xkeycaps

If you are often on the terminal, the caps lock key can be annoying, at least for me. Quite often, I find myself typing a command but only to notice when I am about to hit the return key, it is in capital letters. This pushed me into doing desperate measures such as aliasing a few Linux commands ( alias CD='cd' and alias LS='ls' ) which I use regularly and are victims of my cap lock bad habits.

This got me in the persistent search for a solution to fix this annoyance. Sort of a hack that solve it and give me more freedom over my keyboard. Initially, writing a bash script was my thought but then I needed to know the X server programme responsible for the keyboard settings. I tried the XFCE keyboard settings but I found it limiting.

I finally landed on xkeycaps, the “graphically display and edit the X keyboard mapping”. xkeycaps is a fantastic programme written by Jamie Zawinski. It is a graphical front-end to xmodmap as described by the author. On a Debian system or its derivatives there is a package available in the repository and apt install xkeycaps is all you need.

The keyboard like window.

Once you start the programme xkeycaps will launch two windows, one will ask you to select a keyboard type and layout. The second window is the keyboard simulator that will help you modify your keyboard.

The keyboard and layout window will ask you to choose a keyboard type based on you vendor. Most likely, xkeycaps will pick the vendor, keyboard type and layout for you as it did in my case. However, you may have to review this as it picked the wrong layout, “XFree86; US” instead of “XFree86; United Keyboard”. Both vendor and keyboard type, “PC105” was correctly picked by the programme.

You set your keyboard options here.

On the second window, you have the option to edit the KeySyms of the selected key. You can also exchange, duplicate, disable the key or even restore it to its default state.

Setting are not persistent and will not survive a reboot. once you achieve the right set up, click on the “Write Output” option on the keyboard like window. A dialogue box will appear telling you your settings are written to the file ~/.xmodmap-`uname -n`. Accept it by clicking ok. Now you can add xmodmap .xmodmap-roamer to your .bashrc file. Change ‘roamer’ to your hostname.

xkeycaps is simple programme which can do wonders if you are the kind that love to tinker with your keyboard and customise your own machine. The man page is detailed and rich. For me this was a quest to solve an annoying issue with my keyboard but with a little of time on the man page, I believe my keyboards, at least my main machine, is up for some hacking.

Leave a Reply