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.

3 responses

  1. […] Installation instruction for Linux: I described it in separate blog entry. […]

  2. jcookeman Avatar

    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. http://twistedmatrix.com/documents/current/api/twisted.internet.inotify.html

    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 https://github.com/seb-m/pyinotify.

    Ta.

  3. Artem Avatar
    Artem

    Looks great! Thank you.

    However there is a bug with xmodmap – it produce a high cpu work and freeze for 5-10 seconds on my workstation. Something like https://bugs.launchpad.net/ubuntu/+source/linux/+bug/998310
    The only workaround I’ve found is using sed to change layouts in xkb. Kind of ugly but work.

Leave a reply to jcookeman Cancel reply