I enjoy pair programming: I find it’s a way to both solve problems quicker and exchange knowledge easier. With that said, due to my habit of extensively customizing my environment, there’s a fair chance that my computer will be borderline unusable for other people. A year or two ago I was forced to solve a couple of aspects of this problem, to enable my colleagues to pair program with me on my computer.
Let’s tackle the one of those hurdles:
You and your pairing partner use different keyboard layouts.
I’m making the assumption that these apply to you:
- You use Linux.
- You pair program by having two keyboards.
- You have a second keyboard of a different brand/model than the primary keyboard.
- You don’t use a desktop environment that completely overrides Xorg keyboard configuration (an example would be Gnome).
If any of these don’t apply to you, then I don’t think the contents of this blog post will work for you.
Setting things up
We’ll be doing three things:
- Figuring out what the vendor name and device name are for your second keyboard.
- Writing some Xorg configuration.
- Restarting Xorg a couple of times because getting Xorg files right the first time is impossible.
Vendor and product
If the secondary keyboard is connected by USB (as most are these days), plug it in and run
lsusb. This should result in a list like this:
1 2 3 4 5 6
This particular output is what I get when running
lsusb on my laptop with my Das Keyboard plugged in.
You’re interested in stuff after the colon-separated hexadecimal values, the vendor and product names.
Since the two names are concatenated, it might sometimes be hard to figure out where the vendor name stops.
For this, run
In my case, I’d be looking for the last two lines in this output:
1 2 3 4 5 6 7 8 9 10 11
You can also just run
lsusb -v | grep -e idVendor -e idProduct, since you already know what you’re looking for.
As a side-note, if you’re running Arch you can find all the “named” vendor-product combinations in
/usr/share/hwdata/usb.ids (for other distributions, it should be called
usb.ids too, so just
find for that).
Writing the Xorg configuration
While these will be Arch-specific instructions, I expect the location of the files to be basically the same across most distributions. I’m sure you’ll figure it out.
/etc/X11/xorg.conf.d/ directory you might find a bunch of files called
XX is a number.
The lower the number, the higher the priority.
You’ll have to read through the other files present in this directory to determine what number you should use for your keyboard configuration.
Let’s say you’ve got a default keyboard configuration file called
The contents of the file could be something like this:
1 2 3 4 5 6 7
This would by default set my keyboards to the Colemak layout, with the option of switching to the default US layout (that’s what the lack of text after the trailing comma after
colemak means: default variant).
Here I’ve also added two options: cycling between layouts (or in this case variants) and classic X termination.
Now let’s add an overriding alternate configuration file for the Das Keyboard called
1 2 3 4 5 6 7
| separators on the
These allow you to not only input multiple different vendors/products to match, but also input them in either plain text form or hexadecimal form.
For the hexadecimal form, I haven’t figured out whether you need the
0x or not, so I’ve included both forms.
While you can match against any of the provided vendors/products, remember that if you have both the
MatchProduct lines, then you need to match at least one from each.
As for layout (which is why we did all of this in the first place): set the
XkbVariant to whatever you need.
You can find all available layouts and variants in
Assuming you got the Xorg configuration file right (congratulations if it worked on the first try!), then all you need to do is to restart X.
After that, just plug in the Designated Pair Programming Keyboard in and start hacking!
As mentioned at the start, as a guy with a system that differs a lot from what most people use, fixing the keyboard layout isn’t the only problem to solve. There are other things that I need to do to facilitate efficient pair programming on my machines, but I’ll get to that in a different post.