• You are not logged in.

    Implementing the Wide ergonomic mod(s) under Linux

    • Started by DreymaR
    • 11 Replies:
    • Reputation: 210
    • From: Viken, Norway
    • Registered: 13-Dec-2006
    • Posts: 5,343

    I've started using Linux (Ubuntu) and it's a ball - plus, it has Colemak out of the box! :) But not my Wide(Angle) ergonomic mod unfortunately :(

       CmkIBM-ISO60d-Wide_FengShuiFinger.png
       A PC105/ISO keyboard with Colemak and the AngleWide-LBr mod

    (See for instance this topic by cevgar)

    Well, I set about to remedy that and bumbled about until I got it to work!

    The X server is a massive beast and has a bunch of fun directories to browse that only make half sense to anyone but true wizards. In my Ubuntu install, these are situated under /usr/share/x11/xkb and there are separate 'components' for keycodes (the hardware setup), geometry (how your keyboard looks physically), symbols (what I usually call a 'layout' such as Colemak vs QWERTY), rules (putting it all together) and so on.

    Colemak users may be used to the Symbols component of this beast, as that's where we define which symbols are generated from pressing a key (or rather, from sending a key event corresponding to a certain symbolic Keycode such as <AB03> which means that the 3rd alpha key on row B was pressed - nice!). But that's not enough for me! I want the Symbols component to be about whether you use QWERTY or Colemak or another layout, and unfortunately that's also mixed up with your higher-level mappings which determine the use of AltGr and such (a question that I'd like to see separated from the basic layout choice but that's another matter). So to get what I wanted - a Symbols-independent definition of a keyboard that has some keys moved "physically" around - I had to dig deeper.

    Now, it said in the README for the Geometry files that they'd "override" whatever was in the Keycodes settings so I first tried editing only the Geometry. That made the images of the keyboard look right but didn't actually change the keys pressed so I had to do both after all. The "override" was only in a visual sense.

    [SEE BELOW FOR MY DESCRIPTION AND LINKS]

    My next project is to use the Overlay or Lvl5 feature of the XKB to send different keycodes when you're holding down a modifier - this should amount to an Extend mode like what I've used with PKL under Windows!!!


    UPDATE 2012-07-31:

    I've moved to another Wide variant which also seems to be more popular with other people: AngleWide-Slash, keeping the brackets in the middle.

       Cmk-ISO-AWide35_90d-FingerShui.png
       The AngleWide-Slash ('AWide-35') wide keyboard mod for a PC105/ISO keyboard.

    To see more about that and how I made it work in xkb, head over to the Big Bag of Tricks topic.

    That topic also describes the Extend mappings mentioned above.

    Last edited by DreymaR (31-Jul-2012 10:19:05)

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

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

    Oh noes, seems the "Show Current Layout" image is borked. Not sure whether you could force an update of it, as it seems to be stuck on an old error that I've now fixed?

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

    Offline
    • 0
    • Reputation: 23
    • From: Belgium
    • Registered: 26-Feb-2008
    • Posts: 480

    Hey, implementing Wide as a geometry instead of a layout was a clever thing!  I'll look into this when I have some time for it.

    I have my own Colemak-wide xkb layout, but as you said it's much better to be able to apply the "Wide geometry" independently to any layout.  (I feel the same about other layout-agnostic changes like the Caps Lock key.)

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

    Nice! Maybe you can spot any errors I made.  :)  I should probably make a tidier write-up of what I did, with some files and stuff. Seems that there are bigger differences than I was expecting just from Ubuntu 10.04 to 10.10 though so maybe I need to be careful. Let me know if anything is presented too specifically for other Linux users!

    Maybe you have any ideas on how to make the Extend mod work in Linux using Overlay? From what I understand, the Overlay1 and Overlay2 mappings can be defined (in Symbols?) to provide other keycodes for a key - like, say, a NumPad on the alpha block like many laptops have. If that could be made to work like this I'd be very happy:
    - Pressing and holding CapsLock activates Overlay1, pressing CapsLock plus another modifier (like Ctrl) activates Overlay2. (Maybe one could be press-and-hold, and the other press-to-toggle, even?)
    - In Overlay1, the UNEI keys become the arrow keys, LY Home/End, JH PgUp/PgDn etc (I've described this elsewhere). Interesting to see whether for instance the WR keys could emulate MouseWheelUp/Dn and |?Ø(VK_102/LSGT) could give mouse movement too!

    Then I'd have practically everything my fingers desire.  :)

    I still haven't figured out how to determine which key(s) can switch on the Overlay# layers, or exactly how to map them.

    Last edited by DreymaR (17-Feb-2011 10:48:09)

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

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

    Yay, I'm ready for an update again! :) Here goes then:

    DREYMAR MAKES THE ERGONOMIC ANGLE+WIDE MOD WORK IN LINUX (for all layouts!):

    The task at hand is to make the ergonomic mod a keycode/geometry definition rather than a symbolic layout one.
    Doing so, we allow it to be selected as a keyboard model (based on the generic pc105 International keyboard).
    Thus it becomes independent of which layout (QWERTY/Dvorak/Colemak etc) we've chosen which is nice!
    This is especially important since I think it's a good idea to move the physical key caps around for this mod if you can.
    The minor downsides to this are:
        * For keyboard models that can't use the pc105 codes (like mac or sgi ones) you'll have to edit the relevant files
        * The symbolic names of key codes no longer remain in an intuitive sequence (e.g., <AE12> is now left of <AE07>)


    1) DEFINING THE NEW MOD AS A KEYBOARD MODEL

    To make the system see our new keyboard definition, we need to add the following rules entry to two files, evdev and base:
    [It used to be xorg.xml, but now that's usually just an alias. Evdev is the one in use by Debian-based Linux today.]
    ====== In /usr/share/X11/xkb/rules/evdev.xml ==========
    ====== In /usr/share/X11/xkb/rules/base.xml ===========

        <model>
          <configItem>
            <name>pc105wide</name>
            <description>Generic 105-key (Intl) PC WideErgoMod</description>
            <vendor>Generic</vendor>
          </configItem>
        </model>

    =======================================================

    We also need to describe the keyboard model in evdev/base.lst:
    ====== In /usr/share/X11/xkb/rules/evdev.lst ==========
    ====== In /usr/share/X11/xkb/rules/base.lst ===========

      pc105wide       Generic 105-key (Intl) PC WideErgoMod

    =======================================================

    Now, the main evdev/base files (without .lst and .xml extensions) should've been recompiled based on these changes!
    However, restarting my X Server (Ctrl+Alt+Back if you have that hotkey, or a system restart) didn't make that happen.
    [I hear that from the console, you could remove '/tmp/.X0-lock' followed by a 'startx' command? I couldn't do that.]
    Hence, we'll edit those files manually (because although you're warned not to do that, I didn't see another way).


    2) DEFINING THE NEW KEYBOARD GEOMETRY (so that it shows up right in images)

    This component, apparently, isn't used by the X.Org server itself but by any app which wants to show a keyboard image.
    As such, it's not crucial for keyboard function but it should be taken care of to provide function and avoid confusion.

    The geometry/pc file gets a new entry at the end:
    ====== In /usr/share/X11/xkb/geometry/pc ==============

    // Addition to the /xkb/geometry/pc file: 
    // AngleWide ergonomic mod (by DreymaR, 2011)
    xkb_geometry "pc105wide" {
    
        description= "Generic 105 - WideErgoMod";
    
    {NB: STICK IN A COPY OF THE PC(105) GEOMETRY HERE, THEN DELETE THE DESCRIPTION AND FINALLY 
    REPLACE THE ALPHA SECTION WITH THE ONE BELOW!!! It's a bit long to quote (I'll also have a proper patch file available)}
    
        section "Alpha" {
        top= 61;
        row {
            top= 1;
            keys { <TLDE>, <AE01>, <AE02>, <AE03>, <AE04>,
               <AE05>, <AE06>, <AE12>, <AE07>, <AE08>,
               <AE09>, <AE10>, <AE11>,
               { <BKSP>, "BKSP", color="grey20" }
            };
        };
        row {
            top= 20;
            keys { { <TAB>, "TABK", color="grey20" },
               <AD01>, <AD02>, <AD03>, <AD04>, <AD05>, 
               <AD12>, <AD06>, <AD07>, <AD08>, <AD09>, 
               <AD10>, <AD11>, { <RTRN>, "RTRN", color="grey20" }
            };
        };
        row {
            top= 39;
            keys { { <CAPS>, "CAPS", color="grey20" },
               <AC01>, <AC02>, <AC03>, <AC04>, <AC05>, 
               <BKSL>, <AC06>, <AC07>, <AC08>, <AC09>, 
               <AC10>, <AC11>
            };
        };
        row {
            top= 58;
            keys { { <LFSH>, "LFSH", color="grey20" },
                <AB01>, <AB02>, <AB03>, <AB04>, <AB05>, <LSGT>, 
                <AB10>, <AB06>, <AB07>, <AB08>, <AB09>, 
                { <RTSH>, "RTSH", color="grey20" }
            };
        };
        row {
            top= 77;
            key.shape= "SMOD";
            key.color= "grey20";
            keys { { <LCTL>, "MODK" }, <LWIN>, <LALT>,
               { <SPCE>, "SPCE", color="white" },
               <RALT>, <RWIN>, <MENU>, <RCTL>
            };
        };
        }; // End of "Alpha" section
    
    // Don't think I can get augment or include to work well with a Geometry component...
    //    augment "pc(pc105)"
    // So instead, I've copy-pasted the whole pc105 def and just edited the Alpha section
    
    }; // End of "pc105wide" geometry (by DreymaR 2011)

    =======================================================
    [I first tried include pc(pc105) but that was problematic and led to multiple definitions.
    Augmenting may be safer, but I doubt that works well on a geometry file?
    So the last resort is that the full pc(pc105) definition is copied over and the alpha section edited.]

    So, after all this now we can see the right look in "Show layout" tools, but the keys still act like before!


    3) DEFINING THE CHANGED KEYCODES (so that the keys actually move around)

    The keycodes themselves are by default taken from evdev (default now?) or xfree86 (which links to "base").
    If you're using some other keyboard model you'll have to build your own modded key codes for that model.
    For instance, in the digital_vndr/pc and sgi_vndr/indy codes there are pc105 models with different codes!

    In the base and evdev files you find entries like this one (which was under 'geometry'):
    $pcmodels    =    pc(%m)
    Thus, if pc105wide is listed as a pcmodel the geometry component will be in the pc file, entry pc105wide

    So here's where I start my 'heretical' direct editing of the compiled rules files (CAVEAT EMPTOR):
    ====== In /usr/share/X11/xkb/rules/evdev ==============
    ====== In /usr/share/X11/xkb/rules/base ===============
    ========== Adding to "! $pcmodels = " =================

    ! $pcmodels = pc101 pc102 pc104 pc105 pc105wide

    =======================================================

    Not sure if we need $inetkbds (it lists "internet keyboards" that use special keys, I think) but here goes:
    ====== In /usr/share/X11/xkb/rules/evdev ==============
    ====== In /usr/share/X11/xkb/rules/base ===============
    ========== Under "! $inetkbds = " =====================

                  pc105wide \

    =======================================================
    [The $inetkbds section used to have a line similar to the one in $pcmodels but it changed to this format]

    In the evdev file under "! model = keycodes" only pc98 is listed and the value " * = evdev" is the default.
    For the base file, similarly no pc models are mentioned and it ends with " * = xfree86".
    Since our pc105wide model doesn't use standard xfree86/evdev codes we must introduce a new specific entry:
    ====== In /usr/share/X11/xkb/rules/evdev ==============
    ========== Under "! model  =  keycodes" ===============

      pc105wide    =    evdev(pc105wide)

    =======================================================

    ====== In /usr/share/X11/xkb/rules/base ===============
    ========== Under "! model  =  keycodes" ===============

      pc105wide    =    xfree86(pc105wide)

    =======================================================

    The following two new entries in the keycodes.dir file list the pv105wide definitions.
    This probably isn't necessary now! In newer files, the pc models aren't listed explicitly.
    ====== In /usr/share/X11/xkb/keycodes.dir =============
    ========== Under the relevant files ===================

    -------- a------- evdev(pc105wide)
    -------- a------- xfree86(pc105wide)

    =======================================================
    (The top line for each file has a letter 'd' in it; this means that that it the default for this file.
    The letter 'a' means that it's an alphabetic definition.)

    Now, at the end of the keycodes file itself add this:
    ====== In /usr/share/X11/xkb/keycodes/evdev ===========

    // Addition to the /xkb/keycodes/evdev file: 
    // AngleWide ergonomic mod (by DreymaR, 2011)
    xkb_keycodes "pc105wide" {
    
        <AE12> =  16;
        <AE07> =  17;
        <AE08> =  18;
        <AE09> =  19;
        <AE10> =  20;
        <AE11> =  21;
    
        <AD12> =  29;
        <AD06> =  30;
        <AD07> =  31;
        <AD08> =  32;
        <AD09> =  33;
        <AD10> =  34;
        <AD11> =  35;
    
        <BKSL> =  43;
        alias <AC12> = <BKSL>;
        <AC06> =  44;
        <AC07> =  45;
        <AC08> =  46;
        <AC09> =  47;
        <AC10> =  48;
        <AC11> =  51;
    
        <AB01> =  94;
        <AB02> =  52;
        <AB03> =  53;
        <AB04> =  54;
        <AB05> =  55;
        <LSGT> =  56;
        <AB10> =  57;
        <AB06> =  58;
        <AB07> =  59;
        <AB08> =  60;
        <AB09> =  61;
    
        augment "evdev(evdev)"
    };

    =======================================================

    I think that only evdev is strictly necessary, but the proper thing to do is to change xfree86 as well.
    (I tried to point to the xfree86(pc105wide) definition in the evdev file using 'include', but then
    the chain of includes or something broke so that the keyboard only got partially defined.)

    If you include and then define, the xkbcomp will complain that you're defining the same variable twice.
    Thus, the better way is to define your variables and then augment with the pc105-relevant component.

    ====== In /usr/share/X11/xkb/keycodes/xfree86 =========

    // Addition to the /xkb/keycodes/xfree86 file: 
    // AngleWide ergonomic mod (by DreymaR, 2011)
    xkb_keycodes "pc105wide" {
    
        <AE12> =  16;
        <AE07> =  17;
        <AE08> =  18;
        <AE09> =  19;
        <AE10> =  20;
        <AE11> =  21;
    
        <AD12> =  29;
        <AD06> =  30;
        <AD07> =  31;
        <AD08> =  32;
        <AD09> =  33;
        <AD10> =  34;
        <AD11> =  35;
    
        <BKSL> =  43;
        alias <AC12> = <BKSL>;
        <AC06> =  44;
        <AC07> =  45;
        <AC08> =  46;
        <AC09> =  47;
        <AC10> =  48;
        <AC11> =  51;
    
        <AB01> =  94;
        <AB02> =  52;
        <AB03> =  53;
        <AB04> =  54;
        <AB05> =  55;
        <LSGT> =  56;
        <AB10> =  57;
        <AB06> =  58;
        <AB07> =  59;
        <AB08> =  60;
        <AB09> =  61;
    
        augment "xfree86(basic)"
    };

    =======================================================

    The default xfree86 pc105 definition is (xfree86) but that just includes (basic) adding <BKSL> and <LSGT>.
    So I think it's smoother to work with the 'basic' component of xfree86 directly for pc105wide as well.


    4) GETTING IT UP AND RUNNING

    - I (and erw on the Colemak forum) found that changing layout files isn't enough; you also need to flush the "cache".
        * Otherwise, I have seen keys lose repeat, the geometry images get weird and whatnot.
        * So at this point, delete all the files in /var/lib/xkb/ (the X server makes new ones as necessary).

    - Now restart the X Server (Ctrl+Alt+Backspace or a restart).

    - You should now be able to select, view and use the "PC105 (Wide)" keyboard model with your preferred symbol layout!

    - If troubleshooting is needed, the console command 'setxkbmap -print -verbose 8' may give you an idea what's going on.

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

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

    Perhaps more useful for those who don't actively enjoy headaches: A link to a patch file I made!

    The archive contains two patch files to make and unmake the changes necessary for defining the Wide+Angle ergonomic mod keyboard, selectable as a variant of the PC105 (Intl) Generic model. There are also shell scripts that you could use to install the .patch files with - that'd be the easiest way for most users. Open a term window, make sure the .patch files are in the active directory and run the script with 'sudo sh inst_cmk*.sh'.

    Be warned that this script does modify system files! Use it at your own risk and DO BACK UP YOUR XKB DIR FIRST! Once I managed to frak up my xkb folder to the point of a failure to log in at the next reboot (the solution to that was to boot from a Linux Live Disk and restore the original files in that folder...). But you shouldn't have such problems with this.

    It's been tested on Ubuntu 11.10 (Oneiric). While the changes above should work for any Linux that uses a /usr/share/X11/xkb folder, these patch files will be linked to that current version of the X.Org server I believe since there are small changes in a lot of lines for every new release; if you need another set of files ask and I may be able to produce it (but not promising anything!). Actually selecting the keyboard model may vary, from choosing it in a GUI tool to editing a file like /etc/default/keyboard or xorg.conf depending on your distro.

    Note that I've been fiddling around with the bracket positions because in the end I've come to think that the left bracket to the right and vice versa was too silly. Chime in if you have an opinion on that subject!

    CmkIBM-ISO60d-Wide1b1b_Finger.png

    [edit: I should add what version of the X.Org server Ubuntu Oneiric uses, maybe? According to the 'Xorg -version' command it's "X.Org X Server 1.10.4; Release Date: 2011-08-19. Hope that's useful info.]

    Last edited by DreymaR (14-Nov-2011 09:51:01)

    *** 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-Nov-2011
    • Posts: 90

    @DreymaR

    Woops! It has one additional column.
    I didn't see it.

    Last edited by penguin (14-Nov-2011 12:05:05)

    Debian GNU/Linux Jessie NitroType TypeTest

    Offline
    • 0
    • Reputation: 0
    • From: México
    • Registered: 19-Feb-2012
    • Posts: 2

    @DreymaR

    Thanks, it worked a treat, although I only shifted ZXCVB.

    Offline
    • 0
    • Reputation: 0
    • Registered: 14-Jan-2011
    • Posts: 163

    2 days ago I decided to install Ubuntu along side my windows to implement my layout under linux. I was afraid that it would be hard but it was actually easier than the buggy Autohotkey. Also few days ago my microsoft natural keyboard failed and I had to type on a narrower keyboard and I was really annoyed, but I remembered this wide ergonomic mode and I said I would give it a try until I get my hands on a decent keyboard. I implemented it on windows and loved it very much and from my experience I know how important to have wide angle because narrow angles and bad wrist angle tend to impinge the shoulder and one would suffer from his neck and develop what I call sleeping syndrome (long story, but test and confirmed at least on me :). Anyway, I decided to implement the wide ergo on ubuntu 12.04 LT as well but then I was missing the keycode AC12, and it was not mentioned in the keycode chart image, so I did a search and ended up here lol. Luckily from the above post I know now it is <BKSL> =  43;
        alias <AC12> = <BKSL>, and thus I have my wide ergo implemented now. Thanks for your effort DreymaR; And since you have been working for a while with xkb and it is only my third day, I have a question: I am try to assign swedish letters when I hit AltGr and Shift +AltGr at as follows
    key <AC04> { [        a,    A,  adiaeresis,  Adiaeresis        ]    };
    and I want to assign some keys for navigation as well, but when I hit the Alt it opens unity dash for me and no swedish symbols are generated. Do you have any clue, why is this happening, thanks in advance

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

    If you go to my Big Bag of Tricks topic you'll find my files there for Ubuntu 12.04 that you can have a look at. :) I'm now using the "AngleWide-Slash" mod, that is, brackets in the middle and the Slash/Questionmark key on the old RBr position.

    Your mapping assignment in itself looks okay (bearing in mind that <AC04> is the Colemak T key). I'm guessing there's an options setting that's odd instead: First try using the original symbols/se file to confirm this. Now look for the Options button on the keyboard control panel and see if something's selected there that might interfere with the function of the AltGr or GUI/Win keys.

    Myself, I prefer having the special letters on lv1-2 now. Having them on AltGr mappings disrupts the flow of typing too much I find. It's easier for me to hit AltGr for the occasional brackets, and if I need to code heavily I can just switch to the standard layout.

        Cmk-X-eD-se-usym%2Bfi-awide-sl_mask.png

    Here's my code for the se layout:

        key <AD11> { [         aring,         Aring,         bracketleft,           braceleft ] };// from <AD10>
        key <AD12> { [    adiaeresis,    Adiaeresis,        bracketright,          braceright ] };// from <AC11>
        key <LSGT> { [    odiaeresis,    Odiaeresis,              oslash,            Ooblique ] };// from <AC10>
    Last edited by DreymaR (07-Aug-2012 14:22:00)

    *** 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: 14-Jan-2011
    • Posts: 163
    DreymaR said:

    Myself, I prefer having the special letters on lv1-2 now. Having them on AltGr mappings disrupts the flow of typing too much I find. It's easier for me to hit AltGr for the occasional brackets, and if I need to code heavily I can just switch to the standard layout.

    Indeed, I think so and that its not really what I want to achieve. I am planning to do the same thing as I did under windows: AltGr + s|d|e|f  for navigation and aa -->ä , ii -->å, hh -->ö. The three swedich accents are the only ones I need and I am not planning to develop a third or fourth layer for symbols, as I do not need them very often. Now, I am not sure if I can make the same thing with xkb as I did with autohotkey i.e hitting hh twice within 400 ms to get Swedish accent, and I have to investigate that more. If I found it is not possible then for my wide-mode I have the two keys in the center free so I can assign the Swedish accents to them. I got this freedom because I assigned ]  to shift + Enter , } to shift+Backspace,  + to rightShift + leftShift and of course my shifts are brought one key up to prevent wrist damage and reduce shoulder movement.

    I was googling and found this small program which could come in handy under windows and I hope that it works with autohotekey http://allchars.zwolnet.com/

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

    So, basically Allchars emulates the Compose method? I like Compose, it's logical. My dead key mappings are heavily influenced by the Compose method in that for instance AltGr+comma gives the cedilla dead key. However, I find the need for Shift+apostrophe too cumbersome for a common accent like the umlaut, so there I went my own way and used the semicolon (and put ogonek on 8 instead).

    Putting the äöå in the middle is a good idea I think. I think you'll find it troublesome to implement your other method on xkb, and then you're down to running scripts which I find a bit of a hassle.

    Last edited by DreymaR (02-Aug-2012 13:00:57)

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

    Offline
    • 0