• You are not logged in.
  • Index
  • Technical
  • Problem with TeX-friendly version of Colemak

    Problem with TeX-friendly version of Colemak

    • Started by GanonZD
    • 15 Replies:
    • Reputation: 0
    • Registered: 04-Dec-2015
    • Posts: 6

    I am trying to create a modified version of Colemak inspired by Programmer's Dvorak for Linux Mint, but aimed at writing in LaTeX. The current, experimental version is seen below. Like in Programmer's Dvorak, the top keys produce symbols by default, while holding Shift yields numbers. Occasionally, I want to write many numbers and need some kind of Caps Lock for this purpose, but which only affects the top row and does not capitalize the letters. I have placed this Caps Lock on the "tilde" button and assigned the type "Four level" to all characters I do not want affected by this.

    However, I have two problems:

    First of all, Caps Lock works just right for the symbol row, but still capitalizes alphabetic characters (even if I put my layout on the top of the keyboard list). Secondly, if I try to remove the standard keyboard from the list, I get this lovely message:

    Error activating XKB configuration.
    There can be various reasons for that.

    If you report this situation as a bug, include the results of
    • xprop -root | grep XKB
    • gsettings get org.gnome.libgnomekbd.keyboard model
    • gsettings get org.gnome.libgnomekbd.keyboard layouts
    • gsettings get org.gnome.libgnomekbd.keyboard options

    I have been looking for typing errors for hours. What am I doing wrong?

    default  partial alphanumeric_keys modifier_keys
    
    // Colemak symbols for xkb on X.Org Server 7.x
    // 2006-01-01 Shai Coleman, https://colemak.com/
    
    partial alphanumeric_keys
    xkb_symbols "coltex" {
        include "us"
        name[Group1]= "English (ColTeX)";
    
        key.type[Group1]="FOUR_LEVEL";
    
        key <TLDE> { [ Caps_Lock ]};
    
        key <AE01> { [            bracketleft, grave ] };
        key <AE02> { [            bracketright,           7 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE03> { [            braceleft,   5 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE04> { [            braceright,       3,            threesuperior ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE05> { [            parenleft,      1,        onesuperior ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE06> { [            ampersand,  9 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE07> { [            percent,    0 ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE08> { [            parenright,     2,           twosuperior ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE09> { [            plus,    4, EuroSign ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
        key <AE10> { [            minus,   6, sterling ], type[Group1] = "FOUR_LEVEL_ALPHABETIC"  };
    
        key <AE11> { [        asciicircum, 8 ] };
        key <AE12> { [        numbersign, bar ] };
    
        key <AD01> { [            q,            Q,      dead_tilde ]};
        key <AD02> { [            w,            W,      dead_circumflex ] };
        key <AD03> { [            f,            F,          dead_grave ] };
        key <AD04> { [            p,            P,          dead_acute ] };
        key <AD05> { [            g,            G,     dead_doubleacute ] };
        key <AD06> { [            j,            J ] };
        key <AD07> { [            l,            L,         leftsinglequotemark  ] };
        key <AD08> { [            u,            U,          rightsinglequotemark ] };
        key <AD09> { [            y,            Y  ] };
        key <AD10> { [       backslash,         exclam  ] };
        key <AD11> { [  equal,    slash ] };
        key <AD12> { [ asterisk, quotedbl   ] };
        key <BKSL> { [    underscore, at  ] };
    
        key <AC01> { [            a,            A,          eacute,           Eacute ],type[Group1] = "FOUR_LEVEL_ALPHABETIC" };
        key <AC02> { [            r,            R,           aring,            Aring ] };
        key <AC03> { [            s,            S,           oslash,         Ooblique ] };
        key <AC04> { [            t,            T,              ae,               AE ] };
        key <AC05> { [            d,            D, dead_diaeresis ] };
        key <AC06> { [            h,            H ] };
        key <AC07> { [            n,            N,          leftdoublequotemark ] };
        key <AC08> { [            e,            E,          rightdoublequotemark  ] };
        key <AC09> { [            i,            I, guillemotright ] };
        key <AC10> { [            o,            O, guillemotleft  ] };
        key <AC11> { [    dollar,        apostrophe  ] };
    
        key <AB01> { [            z,            Z, oe, OE ] };
        key <AB02> { [            x,            X,         multiply  ] };
        key <AB03> { [            c,            C,        ccedilla,         Ccedilla ] };
        key <AB04> { [            v,            V,          ssharp ] };
        key <AB05> { [            b,            B ] };
        key <AB06> { [            k,            K  ] };
        key <AB07> { [            m,            M ] };
        key <AB08> { [        comma,         less ] };
        key <AB09> { [       period,      greater  ] };
        key <AB10> { [        semicolon,     colon,    endash,       emdash ] };
    
        key <CAPS> { [    BackSpace,    BackSpace,       BackSpace,        BackSpace ] };
        key <LSGT> { [        asciitilde,   question, quotedbl,    nobreakspace ] };
        key <SPCE> { [        space,        space,           space,     nobreakspace ] };
    
        include "level3(ralt_switch)"
    };
    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Sep-2015
    • Posts: 12

    First of all, Caps Lock works just right for the symbol row, but still capitalizes alphabetic characters (even if I put my layout on the top of the keyboard list).

    FOUR_LEVEL does not use and, therefore, preserves the Lock modifier.  That is, the selected level indeed does not care about Lock, but then the application code (libX11 or whatever), when it sees a lowercase character entered and the Lock modifier set, capitalizes the letter.  You have a few options.  The simplest might be to hack up FOUR_LEVEL (in types/extra) to formally use Lock, but to actually ignore it:

    type "FOUR_LEVEL" {
        modifiers = Shift+Lock+LevelThree;
        map[None] = Level1;
        map[Lock]  = Level1;
        map[Shift] = Level2;
        map[Lock+Shift] = Level2;
        map[LevelThree] = Level3;
        map[Lock+LevelThree] =  Level3;
        map[Shift+LevelThree] = Level4;
        map[Lock+Shift+LevelThree] =  Level4;
        level_name[Level1] = "Base";
        level_name[Level2] = "Shift";
        level_name[Level3] = "Alt Base";
        level_name[Level4] = "Shift Alt";
    };

    However, in your place, I would use one of the eight-level types, and an ISO_Level5_Lock instead of a Caps Lock.  It might be a bit more work, but opens new possibilities.  To see an example of eight-level types put in use, see the Neo layout (in symbols/de).

    What am I doing wrong?

    As your layout mostly works, I doubt that the problems removing the standard layout come from what you show us.

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Dec-2015
    • Posts: 6

    Can I mix eight level with four level, or do I have to go all eight level?

    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Sep-2015
    • Posts: 12

    Can I mix eight level with four level, or do I have to go all eight level?

    You can mix.

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Dec-2015
    • Posts: 6

    I tried, and it generally works quite well (the updated code is seen below). Now I have chosen to use the more easy-to-access MENU key for the purpose instead. However, there is a problem: When ISO_Level5_Lock is activated, I cannot use keys like Super or Alt. Can this be fixed?

    default  partial alphanumeric_keys modifier_keys
    
    //partial alphanumeric_keys modifier_keys
    
    //default  partial alphanumeric_keys modifier_keys
    
    // Colemak symbols for xkb on X.Org Server 7.x
    // 2006-01-01 Shai Coleman, https://colemak.com/
    
    //partial alphanumeric_keys
    
    //default partial alphanumeric_keys modifier_keys
    partial alphanumeric_keys
    xkb_symbols "coltex" {
        name[Group1]= "English (ColTeX)";
    
        include "us"
    
        key.type[Group1] = "EIGHT_LEVEL";
    
        key <TLDE> { [     numbersign,         grave,        NoSymbol,    NoSymbol,    numbersign,         grave,        NoSymbol,    NoSymbol ]};
    
        key <AE01> { [    ampersand,     at,        NoSymbol,     NoSymbol,    ampersand,    at,         NoSymbol,     NoSymbol ]};
        key <AE02> { [    7,         bracketleft,     NoSymbol,     NoSymbol,    bracketleft,       7,         NoSymbol,     NoSymbol ]};
        key <AE03> { [    5,         braceleft,    NoSymbol,     NoSymbol,    braceleft,       5,        NoSymbol,    NoSymbol ]};
        key <AE04> { [    3,         braceright,     threesuperior,     NoSymbol,    braceright,     3,                threesuperior,    NoSymbol ]};
        key <AE05> { [    1,        bracketright,     onesuperior,     NoSymbol,    bracketright,   1,            onesuperior,    NoSymbol ]};
        key <AE06> { [    9,        parenleft,    NoSymbol,    NoSymbol,     parenleft,    9,        NoSymbol,    NoSymbol ]};
        key <AE07> { [    0,        parenright,    NoSymbol,    NoSymbol,    parenright,    0,        NoSymbol,    NoSymbol ]};
        key <AE08> { [    2,        plus,        twosuperior,    NoSymbol,    plus,        2,               twosuperior,     NoSymbol ]};
        key <AE09> { [    4,                asciicircum,    EuroSign,    NoSymbol,    asciicircum,    4,         EuroSign,     NoSymbol ]};
        key <AE10> { [    6,        slash,        sterling,    NoSymbol,    slash,        6,        sterling,    NoSymbol ]};
        key <AE11> { [    8,        asterisk,    NoSymbol,    NoSymbol,    asterisk,    8,        NoSymbol,    NoSymbol ]};
        key <AE12> { [    minus,        bar,        NoSymbol,    NoSymbol,    minus,        bar,        NoSymbol,    NoSymbol ] };
    
        key.type[Group1] = "EIGHT_LEVEL_SEMIALPHABETIC";
    
        key <AD01> { [ q,    Q,      dead_tilde,         NoSymbol,    q,    Q,      dead_tilde,         NoSymbol ] };
        key <AD02> { [ w,    W,      dead_circumflex,    NoSymbol,     w,      W,      dead_circumflex,    NoSymbol ] };
        key <AD03> { [ f,    F,         dead_grave,         NoSymbol,    f,    F,         dead_grave,         NoSymbol ] };
        key <AD04> { [ p,    P,      dead_acute,        NoSymbol,    p,    P,      dead_acute,        NoSymbol ] };
        key <AD05> { [ g,    G,         dead_doubleacute,    NoSymbol,    g,    G,         dead_doubleacute,    NoSymbol ] };
        key <AD06> { [ j,    J,     NoSymbol,         NoSymbol,    j,    J,     NoSymbol,         NoSymbol ] };
        key <AD07> { [ l,    L,      leftsinglequotemark,     NoSymbol,    l,    L,      leftsinglequotemark,     NoSymbol  ] };
        key <AD08> { [ u,    U,      rightsinglequotemark,    NoSymbol,    u,    U,      rightsinglequotemark,    NoSymbol ] };
        key <AD09> { [ y,    Y,    NoSymbol,        NoSymbol,    y,    Y,    NoSymbol,        NoSymbol  ] };
    
        key.type[Group1] = "EIGHT_LEVEL";
    
        key <AD10> { [ backslash,    less,     NoSymbol,    NoSymbol,    backslash,    less,     NoSymbol,    NoSymbol  ] };
        key <AD11> { [ equal,        greater, NoSymbol,    NoSymbol,    equal,        greater, NoSymbol,    NoSymbol ] };
        key <AD12> { [ percent,     EuroSign,NoSymbol,    NoSymbol,    percent,     EuroSign,     NoSymbol,    NoSymbol  ] };
        key <BKSL> { [ underscore,     quotedbl,NoSymbol,    NoSymbol,    underscore,     quotedbl,NoSymbol,    NoSymbol  ] };
    
    
        key.type[Group1] = "EIGHT_LEVEL_SEMIALPHABETIC";
        key <AC01> { [ a,    A,      eacute,            Eacute,        a,    A,      eacute,        Eacute ]};
        key <AC02> { [ r,    R,      aring,            Aring,        r,    R,      aring,        Aring ] };
        key <AC03> { [ s,    S,      oslash,            Ooblique,    s,    S,      oslash,     Ooblique ] };
        key <AC04> { [ t,    T,      ae,            AE,        t,    T,      ae,        AE ] };
        key <AC05> { [ d,    D,    dead_diaeresis,     NoSymbol,    d,    D,    dead_diaeresis, NoSymbol ] };
        key <AC06> { [ h,    H,    NoSymbol,        NoSymbol,    h,    H,    NoSymbol,    NoSymbol ] };
        key <AC07> { [ n,    N,    leftdoublequotemark,    NoSymbol,    n,    N,    leftdoublequotemark,    NoSymbol ] };
        key <AC08> { [ e,    E,    rightdoublequotemark,    NoSymbol,    e,    E,    rightdoublequotemark,    NoSymbol  ] };
        key <AC09> { [ i,    I,     guillemotright,        NoSymbol,    i,    I,     guillemotright,        NoSymbol ] };
        key <AC10> { [ o,    O,    guillemotleft,        NoSymbol,    o,    O,    guillemotleft,        NoSymbol  ] };
    
        key.type[Group1] = "EIGHT_LEVEL";
    
        key <AC11> { [ dollar,        apostrophe,    NoSymbol,    NoSymbol,     dollar,        apostrophe,    NoSymbol,    NoSymbol]};
    
        key.type[Group1] = "EIGHT_LEVEL_SEMIALPHABETIC";
    
        key <AB01> { [ z,    Z,    oe,        OE,        z,    Z,    oe,        OE] };
        key <AB02> { [ x,    X,     multiply,     NoSymbol,    x,    X,     multiply,     NoSymbol] };
        key <AB03> { [ c,    C,      ccedilla,       Ccedilla,    c,    C,      ccedilla,       Ccedilla ] };
        key <AB04> { [ v,    V,      ssharp,        NoSymbol,    v,    V,      ssharp,        NoSymbol ] };
        key <AB05> { [ b,    B,    NoSymbol,    NoSymbol,    b,    B,    NoSymbol,    NoSymbol ] };
        key <AB06> { [ k,    K,    NoSymbol,    NoSymbol,     k,    K,    NoSymbol,    NoSymbol  ] };
        key <AB07> { [ m,    M,    NoSymbol,    NoSymbol,    m,    M,    NoSymbol,    NoSymbol ] };
    
        key.type[Group1] = "EIGHT_LEVEL";
    
        key <AB08> { [ comma,    semicolon,    NoSymbol,    NoSymbol,    comma,    semicolon,    NoSymbol,    NoSymbol ] };
        key <AB09> { [ period,    question,    NoSymbol,    NoSymbol,    period,    question,    NoSymbol,    NoSymbol  ] };
        key <AB10> { [ minus,    exclam,        endash,        emdash,        minus,    exclam,        endash,        emdash ] };
    
        key <CAPS> { [ BackSpace,    BackSpace,    BackSpace,    BackSpace,    BackSpace,    BackSpace,    BackSpace,    BackSpace ] };
        key <LSGT> { [ asciitilde,    colon,        nobreakspace,    NoSymbol,     asciitilde,    colon,        nobreakspace,    NoSymbol] };
        key <SPCE> { [ space,    space,        space,        nobreakspace,    space,        space,        space,        nobreakspace ] };
    
        key.type[Group1] = "ONE_LEVEL";
    
        key <MENU> { [ISO_Level5_Lock] };
    
        include "level5(ralt_switch)"
        include "level3(ralt_switch)"
    
    };
    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Sep-2015
    • Posts: 12

    When ISO_Level5_Lock is activated, I cannot use keys like Super or Alt. Can this be fixed?

    In principle, the level-5 lock should not interfere with Alt and Super.  If it does, it is an application-specific problem.  For example, I guess that Emacs works just nice.  Most probably, problematic applications get confused by the additional set modifier they cannot interpret (and really should ignore).

    For workarounds, there are several possibilities.  At the current state, possibly the simplest you can try is to comment in EIGHT_LEVEL_LEVEL_FIVE_LOCK in types/level5, use this type for the number keys, and use Num_Lock instead of ISO_Level5_Lock.  The hope is that by pretending that your level-5 lock is a NumLock, applications will understand that they should ignore it.  And if this does not work, the problem can very likely be reproduced with a real NumLock in a conventional layout, which is good if you plan to file bug reports.

    The second possibility is to go back to the four level scheme, using the hacked FOUR_LEVEL type.

    The third possibility is to use not one eight-level layout, but two groups with four levels each.  So you have the first group with the numbers on the shifted level, the second group mostly identical to it with numbers on the unshifted level.  For the key for switching, you could use ISO_Next_Group.  I think this has good chances for success.

    The fourth possibility is by far the most complicated:  You use explicit actions to redirect key to itself, and simultaneously remove and add modifiers as necessary.  An untested example of how this will look like:

    key <AE04> {
        symbols[group1] = [ 3, braceright, threesuperior, NoSymbol,    braceright, 3, threesuperior, NoSymbol ],
        actions[group1] = [ NoAction(), NoAction(), NoAction(), NoAction(), RedirectKey(key=<AE04>, clearMods=Mod3, mods=Shift), RedirectKey(key=<AE04>, clearMods=Shift+Mod3), RedirectKey(key=<AE04>, clearMods=Mod3), NoAction() ]
    };

    For keys that should be not affected by the level-5 lock, leave out the Shift from mods and clearMods.  Depending on the version of the X-Server, this should get even the worst applications to cooperate.  For X servers before 1.14 (as far as I remember), autorepeat will slow by a factor of 2;  for X-servers before 1.12 (as far as I remember), Gtk3 applications will not work.

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Dec-2015
    • Posts: 6

    I actually tried out the group approach, since this seemed to me the “correct” way to do it. However, curiously, ISO_Next_Group switched to another keyboard setup instead of a different group within the same setup. I haven't found a way to get this to work.

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

    I hate the group solution, as I want groups to be about writing Greek and suchlike.

    *** 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: 17-Sep-2015
    • Posts: 12
    GanonZD said:

    However, curiously, ISO_Next_Group switched to another keyboard setup instead of a different group within the same setup. I haven't found a way to get this to work.

    What do you mean with “setup”?

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Dec-2015
    • Posts: 6

    I mean the content of my ”xkb_symbols "coltex"”. That is one setup with possibly several groups in it (which are technically different “layouts,” hence I avoided using that word). On the other hand, I might have many setups (e.g. the standard Colemak or QWERTY or Dvorak or whatever).

    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Sep-2015
    • Posts: 12

    I am not sure that I understand, but I guess what you consider as a setup really boils down to groups.  I suspect you did something like this:

    xkb_symbols "coltex" {
      // ...
      key <AE04> {
          symbols[group1] = [ 3, braceright, threesuperior, NoSymbol ],
          symbols[group2] = [ braceright, 3, threesuperior, NoSymbol ]
      }
      // ...
    };

    and then activated this colemak and other stuff like QWERT in the GUI layout selection, or using setxkbmap.  If so, you really should do it like this:

    xkb_symbols "colmak" {  // That already exist somewhere, I suppose...
      // ...
      key <AE04> {
          symbols[group1] = [ 3, braceright, threesuperior, NoSymbol ]
      }
      // ...
    };
    xkb_symbols "coltex" {
      // ...
      key <AE04> {
          symbols[group1] = [ braceright, 3, threesuperior, NoSymbol ]
      }
      // ...
    };

    and then activate both coltex and colmak, and whatever else you need, exactly as if coltex and colemak were no more related than coltex and Dvorak.

    Offline
    • 0
    • Reputation: 0
    • Registered: 04-Dec-2015
    • Posts: 6

    The first solution is exactly what I tried. How come it doesn't work? The second solution requires me to use two of the available four keyboard slots.

    Offline
    • 0
    • Reputation: 0
    • Registered: 17-Sep-2015
    • Posts: 12

    The first solution is exactly what I tried. How come it doesn't work? The second solution requires me to use two of the available four keyboard slots.

    What you now call “slot” and what you called “setup” before is what XKB calls “group”.  And yes, there are only four of them.  So basically, there is one hierarchy less in XKB that you assumed.  For why it does not work, I guess that your second “setup” overwrote the second group in your first “setup”, as the code that assembles the “setups” into the overall keyboard layout probably assumes that one “setup” has exactly one group.

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

    This thing about groups doesn't seem completely robust. What I mean is, you can select up to four layouts in the GUI selector or with setxkbmap for instance. These will be assigned group numbers 1–4 depending on the order they were selected in (or you can reorder them in the GUI layout selector).

    But what if your layout contains stuff like the above example, specifying both group1 and group2 symbols? What happens then, if you select that layout and another in the layout selector?

    Aren't there some bugs that make things not work as well for non-group1 layouts, too?

    Last edited by DreymaR (11-Dec-2015 13:43:47)

    *** 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: 17-Sep-2015
    • Posts: 12

    But what if your layout contains stuff like the above example, specifying both group1 and group2 symbols? What happens then, if you select that layout and another in the layout selector?

    I have no idea whether the behaviour in such a case is documented somewhere.  But of course, it is easy to just try what happens in practice.

    Aren't there some bugs that make things not work as well for non-group1 layouts, too?

    Non-group-1 indeed bring some problems, but I am not sure if one can call them bugs.  One problem is that the content of additional groups is not build from scratch, but from group 1 (or the previous group, I am not sure).  A typical example up to recently was when us(intl) was used as group 1 and de as group 2.  us(intl) modifies the LSGT key, however, de relied on inheriting the settings from pc, which were overwritten by us(intl), so the LSGT was not working properly in de.  In that case, making de the group 1 layout would have been enough to work around the issue.  The other problem is that options are applied to group 1 only.  If an option maps a key different than a non-group-1, the non-group-1 ignores the option (mostly; see level3(ralt_alt) for a brute-force “fix” for one special case).

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

    Thanks for insightful comments, 509!

    If layouts such as de depends on implicit inheritance that isn't always dependable, then indeed I'd say there's a bug in either the xkb system or the symbols files. ;-)

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

    Offline
    • 0
      • Index
      • Technical
      • Problem with TeX-friendly version of Colemak