The Artima Developer Community
Sponsored Link

Python Buzz Forum
Sane At and Hash keys on Debian

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Aaron Brady

Posts: 576
Nickname: insommeuk
Registered: Aug, 2003

Aaron Brady is lead developer for Crestsource
Sane At and Hash keys on Debian Posted: Nov 17, 2013 11:34 AM
Reply to this message Reply

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.
Latest Python Buzz Posts
Latest Python Buzz Posts by Aaron Brady
Latest Posts From insom.me.uk

Advertisement

I say sane, and I’m not being totally fair:

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).

This is /usr/share/X11/xkb/symbols/insom:

partial default alphanumeric_keys
xkb_symbols "basic" {
    include "gb(basic)"
    name[Group1]="English (UK, Sane @/#)";
    key <AE02>  { [2, at, twosuperior, oneeighth ] };
    key <AE03>  { [3, numbersign, threesuperior, sterling ] };
    key <AC11>  { [apostrophe, quotedbl, dead_circumflex, dead_caron] };
    include "level3(ralt_switch_multikey)"
};

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.

<layout>
  <configItem>
    <name>insom</name>

    <shortDescription>en</shortDescription>
    <description>English (UK, Sane @/#)</description>
    <languageList>
      <iso639Id>eng</iso639Id>
    </languageList>
  </configItem>
</layout>

Read: Sane At and Hash keys on Debian

Topic: Live Programming, Walkabout.js Previous Topic   Next Topic Topic: I Love My Virtual Desktop

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use