• You are not logged in.

    Understanding layouts on *nix

    • Started by pinkyache
    • 7 Replies:
    • Reputation: 7
    • Registered: 21-Apr-2010
    • Posts: 818

    Please can someone give me pointers towards guides for keyboard layout development (how to make and switch layouts etc) for a *nix environment, that's the console and X, and most of the bits between.

    I've managed to erase previous encounters cleanly from my brain.  (Probably for my own sanity.)

    Last edited by pinkyache (13-Jun-2013 15:28:12)

    --
    Physicians deafen our ears with the Honorificabilitudinitatibus of their heavenly Panacaea, their sovereign Guiacum.

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Apr-2013
    • Posts: 538

    Editing a layout is pretty easy - just follow the format.  (For example, here is my ordinary, wide colemak layout excerpted from /usr/share/X11/xkb/symbols/us.)  What I still haven't figured out is how to add a completely new layout.

    With some command keys like ctrl/caps/esc, sometimes doing it via the symbols doesn't work or leads to side-effects.  In this case, you have to modify /usr/share/X11/xkb/keycodes/evdev directly, which changes the definitions of the keycodes being sent to you.  This is a bit more dangerous, since unlike with the symbols, switching layouts does not change any keycodes back!   This diff demonstrates the evdev I use for Ctrl -> Caps -> Esc -> Ctrl.

    Last edited by lalop (13-Jun-2013 17:43:10)
    Offline
    • 0
    • Reputation: 7
    • Registered: 21-Apr-2010
    • Posts: 818

    Rewind, what's a symbol?

    --
    Physicians deafen our ears with the Honorificabilitudinitatibus of their heavenly Panacaea, their sovereign Guiacum.

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Apr-2013
    • Posts: 538

    As in, the files in /usr/share/X11/xkb/symbols, which define the layouts.  If redefining command keys that way is buggy, you might have to go dirty and straight to the /usr/share/X11/xkb/keycodes/evdev keycodes.

    Offline
    • 0
    • Reputation: 7
    • Registered: 21-Apr-2010
    • Posts: 818

    Bless you lalop, what's a symbol and an evdev?   I've found a couple of resources - so probably will come back here - when it all makes sense.  I was really after a 'the knee bones connected to the thigh bone' explanation.

    --
    Physicians deafen our ears with the Honorificabilitudinitatibus of their heavenly Panacaea, their sovereign Guiacum.

    Offline
    • 0
    • Reputation: 214
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,362

    You know, XKB was never easy and you probably can't get an easy explanation. The best I've seen so far has to be these:
    http://hektor.umcs.lublin.pl/~mikosmul/ … s-xkb.html
    https://help.ubuntu.com/community/Howto … efinitions

    Even reading those thoroughly didn't tell me everything I needed to know but please start there at least. XKB editing has to be an undertaking and a growing experience. ;)

    As for your questions:

    'Symbols' are what you use in your layout to make the X.Org server send the right codes to the input stream in response to key events.
    (In more plain English, that means that when you press the A key and as a result an <AC01> key event happens, your symbols file entry tells the server to send an 'a' input event into the stream for most layout entries – of course, if the current symbols entry is Greek an α (alpha) code is sent instead.)

    The 'evdev' and 'xfree86' files are versions or "forks" of the X.Org server; that's how software often happens in the *nix world, competing projects that may or may not branch and merge and create something new and wonderful and possibly confusing. As of right now, 'evdev' is the most common flavor and for Ubuntu at least editing the evdev files is enough (but I always edit the xfree86 ones as well to ensure compliance – they're very similar by the way). Sometimes there are just shortcuts instead of a file which means that that fork has been merged into another and just the reference to it remains for compatibility reasons.

    Don't expect this to get easy; it gives me a headache and I've spent a *lot* of time and energy on it over the past couple of years as you may have noticed!

    Last edited by DreymaR (14-Jun-2013 08:58:34)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Apr-2013
    • Posts: 538

    To be more exact, when you press the A button the keycode 38 gets sent.  The evdev line:

    <AC01> = 38;

    tells xorg to interpret it as <AC01>, which is then mapped to a symbol in one of our layouts.  In my colemak layout, for instance, you can read this off the line:

    key <AC01> { [            a,            A,          Left,           Aacute ] };

    so you can read directly (and rather easily modify) the symbols that result from your triggering the A button --> keycode 38 --> <AC01>.

    In particular, the symbol A results if you're holding shift, Left if you're holding Altgr, and Acacute (whatever that is) if you're holding Altgr+shift.

    Last edited by lalop (14-Jun-2013 09:22:42)
    Offline
    • 0
    • Reputation: 214
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,362

    I was trying not to confuse pinkyache with talk about keycode aliases so i chose the human-friendly approach. You rarely need to mess with the real codes unless you're doing the heavy stuff. For someone not yet familiar with the beginner term 'symbols' that could get a bit overwhelming I fear? ;)

    It's a bit inaccurate to talk about 'the evdev line' like that. There are evdev files in other places so the most correct reference is to the keycodes/evdev component.

    Aacute is simply the capital A with an acute accent (Á). You've remapped the lv3 (AltGr) but not the lv4 (AltGr+Shift) shift state. For consistency, you should probably plop a Left into the lv4 state as well. Unfortunately, I haven't had success with adding Shift+Left there so the dearly beloved shift-arrow selecting is still off my menu. That kind of thing works ever so well in PKL for Windows. :(

    Last edited by DreymaR (14-Jun-2013 10:24:41)

    *** Learn Colemak in 2–5 steps with Tarmak! ***
    *** Check out my Big Bag of Keyboard Tricks for Win/Linux/TMK... ***

    Offline
    • 0