Tags: klc

Pi day: Pi on the keyboard

On my computers I am using Windows, Linux, and sometimes MacOS. Regarding the keyboard layout, I prefer the US English layout – it is just so much better for programming, anything you do on the shell, or whatever. On my Windows Desktop, I have designed my own keyboard layout (using Microsoft Keyboard Layout Creator) that is based on the standard US English configuration: it adds the German special characters (ä, ö, ü, ß), as well as many mathematical and scientific symbols, including Greek letters, which are used very often in science.

Recently, I have bought a new used laptop, ordered a US English replacement keyboard on ebay. The machine is running Linux. So far, so good. However, I did not want to have to go over the hassle of assigning my own special functions to the keyboard keys again (even though there are tools such as Keyboard Layout Editor available). I have not found any program that can automatically convert a Windows keyboard layout into its Linux counterpart. That is why – with some creative help from these regular expressions – I have made my own python script to convert from Windows to Linux. It turns out, that the most annoying part is the conversion of the key identifiers – these have very different names in the two operating systems.

However, eventually I figured it out, merged the generated file with my /usr/share/X11/xkb/symbols/us file, and now I am enjoying the easy access to π (via AltGr-p) and also Π (via Shift-AltGr-p) on my keyboard. Happy Pi day! Ok, The article is a day late. Happy belated Pi day! Or how about this (in German): Fröhlichen Π Tag!

I admit, I might spend too much time on these things, but it just makes me happy when it all works out automatically – or at least semi-automatically. I dislike repetitive tasks.

xkcd - Automation
xkcd – Automation

If you want to check out the script, or my keyboard layout, you can download it from github: Keyboard Layout Converter (GPL v3).