This post originated from an RSS feed registered with Python Buzz
by Aaron Brady.
Original Post: Sane At and Hash keys on Debian
Feed Title: insom.me.uk
Feed URL: http://feeds2.feedburner.com/insommeuk
Feed Description: Posts related to using Python. Some tricks and tips, observations, hacks, and the Brand New Things.
I learned to type on a US keyboard. This is mostly because that was the default
in DOS if you didn’t bother to change it and, being Irish, I didn’t see any
reason why I would pick English (British) as a key layout.
Early computers that I had access to (8088 represent) were US imports
previously used for industrial control applications at my dad’s work, so
the keycaps matched what happened on the screen, too.
As I learned to program, especially in C, the fact that US keyboards’ default
to putting # under Shift-3 was far more useful than £ was. (We still
used £ in Ireland at that point, but I personally used # a lot more).
Since moving the UK, I’ve endeavoured to learn to type like a Brit.
It was going well until a couple of years ago, when I got a MacBook Pro
from work. Even with the British keyboard option, Apple makes Shift-2
into @. In a worst of both worlds situation though, it also sets Shift-3 to
be a £.
I fixed the latter with a Mac keyboard layout called Programmers British,
pretty much turning a MacBook Pro British keyboard into the US keyboards of
my youth. I don’t think I could work without this keyboard layout.
Now, when I go back to using my personal Dell laptop I find myself pressing
all of the wrong keys. I’ve resisted changing this because I like to train
myself to use computers as I find them: as a System Administrator I use
lots of computers and keyboards that are not set up just like I want, and you
need to roll with it. This is fine for occasional use, but when you’re trying
to get real work done it’s infuriating.
I found an Ubuntu guide for custom keyboard layouts and a bit more
Googling around and digging into XKB got me what I needed. The process is
not painless, even when you do what appears to be the ‘right thing’. You need
to add a file in /usr/share (which isn’t great) and you need to edit a file
which is provided by the distribution (which really isn’t great).
It’s actually pretty straightforward what’s going on here, identifiers like
<AE02> map on to physical keys and the { } contains a 4-tuple of the
key, key with shift, key with alt green, and key with shift and alternate
green.
It’s nice that we’re keeping the copy & paste down by including the
basic UK layout gb(basic), so it’s just keys we’re overriding here. As
well as changing the behaviour of Shift-2 and Shift-3, I’m changing
Shift-' — otherwise there wouldn’t be a way to output a double quote.
Sadly, we need to edit /usr/share/X11/xkb/rules/evdev.xml and add a stanza
of XML. This is so that the Region and Language / Layouts pane in GNOME
knows that we’ve added a new language.
You may be able to select this language without logging out and in, but for me
it appeared in the languages bar with no text (though it did work). Logging
back in or even rebooting should cause all the right things to fall into place.