Implementation of my keyboard layout for Linux

In one of my last posts I described keyboard layout I use. I had to switch to Linux recently and typing without this layout was very irritating. I had to recreate it for linux. Here is a github repo, where you can find a code and installation instructions.

First version of my layout used remapping right cmd to mod_switch as described in this article. Sadly for some reason IntelliJ Idea and some parts of Ubuntu unity decided to ignore this mapping, because it looks like they sometimes do not go directly to xorg when parsing keyboard input. I created intelliJ Idea bug entry for it.
Final version that works everywhere parses raw input from /dev/input and it works well. Problem was with the fact that there needs to be separate thread for each device, so I had to listen for new devices appearing using pyinotify. I tried to comment my code as well as I could, so if you are interested how I did it I recommend looking at the code.

There’s a claim that pyinotify used to have bad performance, but given that it’s from 4 years ago it’s on my todo list to check if running pyinotify on small subdirectory affect performance of the rest of a system .

Another problem that I faced is a fact that my layout requires that right cmd is close enough to be conveniently reachable by a thumb. Normal keyboards have much wider space than mac keyboard. This forced me to plug mac bluetooth keyboard into a Linux desktop. And this caused another problem. Mac keyboards have artificial delay on caps lock to prevent accidental clicking. It is easy to remove it on os x, but I couldn’t find a way to remove it on Linux. Sadly I have ESC remapped under caps lock, and given how important key it is in VIM I want it to be responsive. What I did first is I ordered a cheap rip-off of mac keyboard. Sadly it was sometimes dropping bluetooth connection, keys were sometimes jamming and I didn’t like feel of the keys. Finally I ordered a more expensive mac keyboard from Logitech, which works very well so far. It had some trouble pairing with Linux, but with some hacking it’s easy to work around.

About kozikow

I am working with data for quantitative hedge fund, GSA capital. I previously analysed Google Search logs. I am primarily blogging about Data science, Emacs and programming contests like TopCoder.


  1. Did you ever get a round to determining if pyinotify was indeed still suffering from poor performance? I notice Twisted supports inotify, but Twisted always comes with with a big investment in time.

    I’m simply trying to prototype an idea I will later implement in Go or C depending on binding and library support.

    Most commits to pyinotify are several years old


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s