Score:2

xkb options overriding special keyboard layout

br flag

I have made a special Spanish keyboard layout that includes the German ß on AltGr-s, and the Scandinavian æ Æ (ae, AE), ø Ø (oe, OE), and å Å (aring, Aring), on AltGr-e, AltGr-E, AltGr-o, AltGr-O, AltGr-a, and AltGr-A, respectively. The € (EuroSign) has been moved from AltGr-e to AltGr-5.

This worked great on Ubuntu Budgie 21.04. I since moved back to Ubuntu Budgie 20.04 LTS (fresh install) on the same machine, copied over the custom layout, and did setxkbmap {custom_layout}. Suddenly, on AltGr-e I've got €, and on AltGr-5 I've got ½. I am not capable of seeing what is going wrong with the setup below. Can you help?

// Modified for a real Spanish keyboard by Jon Tombs.

default  partial alphanumeric_keys
xkb_symbols "basic" {

    include "latin(type4)"

    name[Group1]="Spanish";

    key <AE01>  { [         1,     exclam,          bar,   exclamdown ] };
    key <AE03>  { [         3, periodcentered, numbersign,   sterling ] };
    key <AE04>  { [         4,     dollar,   asciitilde,       dollar ] };
    key <AE06>  { [         6,  ampersand,      notsign,  fiveeighths ] };
    key <AE11>  { [apostrophe,   question,    backslash, questiondown ] };
    key <AE12>  { [exclamdown, questiondown, dead_tilde,   asciitilde ] };

    key <AD11>  { [dead_grave, dead_circumflex, bracketleft, dead_abovering ] };
    key <AD12>  { [      plus,   asterisk, bracketright,  dead_macron ] };


    key <AC01>  { [         a,              A,     aring,       Aring ] };
    key <AD03>  { [         e,              E,        ae,          AE ] };
    key <AC10>  { [    ntilde, Ntilde,   asciitilde, dead_doubleacute ] };
    key <AC11>  { [dead_acute, dead_diaeresis, braceleft,   braceleft ] };
    key <TLDE>  { [ masculine, ordfeminine,    backslash,   backslash ] };

    key <BKSL>  { [  ccedilla,   Ccedilla,   braceright,   dead_breve ] };

    include "level3(ralt_switch)"
};

partial alphanumeric_keys
xkb_symbols "winkeys" {

    include "es(basic)"
    name[Group1]="Spanish (Win keys)";
    include "eurosign(5)"
};

partial alphanumeric_keys
xkb_symbols "Sundeadkeys" {

    include "es(basic)"

    key <AC11>  { [dead_acute, dead_diaeresis, braceleft, braceleft ]   };
    key <AD11>  { [dead_grave, dead_circumflex, bracketleft, dead_abovering ] };
};

partial alphanumeric_keys
xkb_symbols "sundeadkeys" {

    include "es(Sundeadkeys)"

    name[Group1]="Spanish (with Sun dead keys)";
};

partial alphanumeric_keys
xkb_symbols "nodeadkeys" {

    include "es(basic)"

    name[Group1]="Spanish (no dead keys)";

    key <AD11>  { [     grave, asciicircum,  bracketleft,      degree ] };
    key <AD12>  { [      plus,   asterisk, bracketright,       macron ] };
    key <AD03>  { [         e,              E,        ae,          AE ] };
    key <AC10>  { [    ntilde, Ntilde,   asciitilde, dead_doubleacute ] };
    key <AC10>  { [    ntilde,     Ntilde,   asciitilde,  doubleacute ] };
    key <AC11>  { [     acute,  diaeresis,    braceleft,    braceleft ] };
    key <BKSL>  { [  ccedilla,   Ccedilla,   braceright,        breve ] };
    key <AB10>  { [     minus, underscore, dead_belowdot,    abovedot ] };
};

// Spanish mapping (note R-H exchange)
partial alphanumeric_keys
xkb_symbols "dvorak" {

    name[Group1]="Spanish (Dvorak)";

    key <TLDE> {[  masculine, ordfeminine, backslash, degree        ]};
    key <AE01> {[          1, exclam, bar, onesuperior          ]};
    key <AE02> {[          2, quotedbl, at, twosuperior         ]};
    key <AE03> {[          3, periodcentered, numbersign, threesuperior ]};
    key <AE04> {[          4, dollar, asciitilde, onequarter        ]};
    key <AE05> {[          5, percent, EuroSign, fiveeighths        ]};
    key <AE06> {[          6, ampersand, notsign, threequarters     ]};
    key <AE07> {[          7, slash, onehalf, seveneighths      ]};
    key <AE08> {[          8, parenleft, oneeighth, threeeighths    ]};
    key <AE09> {[          9, parenright, asciicircum           ]};
    key <AE10> {[          0, equal, grave, dead_doubleacute        ]};
    key <AE11> {[ apostrophe, question, dead_macron, dead_ogonek    ]};
    key <AE12> {[ exclamdown, questiondown, dead_breve, dead_abovedot   ]};

    key <AD01> {[     period, colon, less, guillemotleft                ]};
    key <AD02> {[      comma, semicolon, greater, guillemotright        ]};
    key <AD03> {[     ntilde, Ntilde, lstroke, Lstroke          ]};
    key <AD04> {[          p, P, paragraph              ]};
    key <AD05> {[          y, Y, yen                    ]};
    key <AD06> {[          f, F, tslash, Tslash             ]};
    key <AD07> {[          g, G, dstroke, Dstroke           ]};
    key <AD08> {[          c, C, cent, copyright            ]};
    key <AD09> {[          h, H, hstroke, Hstroke           ]};
    key <AD10> {[          l, L, sterling               ]};
    key <AD11> {[ dead_grave, dead_circumflex, bracketleft, dead_caron  ]};
    key <AD12> {[       plus, asterisk, bracketright, plusminus     ]};

    key <AC01> {[          a, A, aring, Aring               ]};
    key <AC02> {[          o, O, oslash, Oslash             ]};
    key <AC04> {[          u, U, aring, Aring               ]};
    key <AC05> {[          i, I, oe, OE                 ]};
    key <AC06> {[          d, D, eth, ETH               ]};
    key <AC07> {[          r, R, registered, trademark          ]};
    key <AC08> {[          t, T, thorn, THORN               ]};
    key <AC09> {[          n, N, eng, ENG               ]};
    key <AC10> {[          s, S, ssharp, section            ]};
    key <AC11> {[ dead_acute, dead_diaeresis, braceleft, dead_tilde ]};
    key <BKSL> {[   ccedilla, Ccedilla, braceright, dead_cedilla    ]};

    key <LSGT> {[       less, greater, guillemotleft, guillemotright    ]};
    key <AB01> {[      minus, underscore, hyphen, macron        ]};
    key <AB02> {[          q, Q, currency               ]};
    key <AB03> {[          j, J                     ]};
    key <AB04> {[          k, K, kra                    ]};
    key <AB05> {[          x, X, multiply, division         ]};
    key <AB06> {[          b, B                     ]};
    key <AB07> {[          m, M, mu                 ]};
    key <AB08> {[          w, W                     ]};
    key <AB09> {[          v, V                     ]};
    key <AB10> {[          z, Z                     ]};

    include "level3(ralt_switch)"
};

partial alphanumeric_keys
xkb_symbols "cat" {

    include "es(basic)"

    name[Group1]="Catalan (Spain, with middle-dot L)";

    key <AC09>  { [     l,      L,      0x1000140,  0x100013F ] };
};

partial alphanumeric_keys
xkb_symbols "ast" {

    include "es(basic)"

    name[Group1]="Asturian (Spain, with bottom-dot H and bottom-dot L)";

    key <AC06>  { [     h,      H,      0x1001E25,  0x1001E24 ] };
    key <AC09>  { [     l,      L,      0x1001E37,  0x1001E36 ] };
};

// Copied from macintosh_vndr/es
partial alphanumeric_keys
xkb_symbols "mac" {
    include "es"
    name[Group1]= "Spanish (Macintosh)";
};

partial alphanumeric_keys
xkb_symbols "olpc" {

    // http://wiki.laptop.org/go/OLPC_Spanish_Keyboard

    include "us(basic)"
    name[Group1]="Spanish";

    key <AE00> { [    masculine,    ordfeminine      ] };
    key <AE01> { [            1,         exclam,             bar ] };
    key <AE02> { [            2,       quotedbl,              at ] };
    key <AE03> { [            3,     dead_grave,      numbersign,   grave           ] };
    key <AE05> { [            5,        percent,        EuroSign,   dead_circumflex ] };
    key <AE06> { [            6,      ampersand,         notsign ] };
    key <AE07> { [            7,          slash,       backslash ] };
    key <AE08> { [            8,      parenleft                         ] };
    key <AE09> { [            9,     parenright                         ] };
    key <AE10> { [            0,          equal                  ] };
    key <AE11> { [   apostrophe,       question                  ] };
    key <AE12> { [   exclamdown,   questiondown                  ] };

    key <AD03> { [            e,              E,              ae,   AE ] };
    key <AD11> { [   dead_acute, dead_diaeresis,           acute,   dead_abovering  ] };
    key <AD12> { [  bracketleft,      braceleft                  ] };

    key <AC01> { [            a,              A,           aring,            Aring ]};
    key <AC10> { [       ntilde,        Ntilde                  ] };
    key <AC11> { [         plus,       asterisk,      dead_tilde ] };
    key <AC12> { [ bracketright,     braceright,      section    ] };

    key <AB08> { [        comma,      semicolon                  ] };
    key <AB09> { [       period,          colon                  ] };
    key <AB10> { [        minus,     underscore                  ] };

    key <I219> { [         less,        greater,  ISO_Next_Group ] };

    include "level3(ralt_switch)"
};

partial alphanumeric_keys
xkb_symbols "olpcm" {

    // Mechanical (non-membrane) OLPC Spanish keyboard layout.
    // See: http://wiki.laptop.org/go/OLPC_Spanish_Non-membrane_Keyboard

    include "us(basic)"
    name[Group1]="Spanish";

    key <AE00> { [    questiondown,    exclamdown, backslash      ] };
    key <AE01> { [            1,         exclam,             bar ] };
    key <AE02> { [            2,       quotedbl,              at ] };
    key <AE03> { [            3,     dead_grave,      numbersign,   grave           ] };
    key <AE04> { [            4,     dollar,     asciitilde,     dead_tilde ] };
    key <AE05> { [            5,        percent,     EuroSign,   dead_circumflex ] };
    key <AE06> { [            6,      ampersand,         notsign ] };
    key <AE07> { [            7,          slash,       backslash ] };   // no '\' label on olpcm, leave for compatibility
    key <AE08> { [            8,      parenleft,    masculine                ] };
    key <AE09> { [            9,     parenright,    ordfeminine                 ] };
    key <AE10> { [            0,          equal                  ] };
    key <AE11> { [   apostrophe,       question                  ] };

    key <AD03> { [            e,              E,        ae,      AE ] };
    key <AD11> { [   dead_acute, dead_diaeresis,     dead_abovering, acute  ] };
    key <AD12> { [  plus,      asterisk                  ] };

    key <AC01> { [            a,              A,           aring,            Aring ]};
    key <AC10> { [       ntilde,        Ntilde                  ] };
    key <AC10> { [       ntilde,        Ntilde                  ] };
    // no AC11 or AC12 on olpcm

    key <AB08> { [        comma,      semicolon                  ] };
    key <AB09> { [       period,          colon                  ] };
    key <AB10> { [        minus,     underscore                  ] };

    key <AA02>  { [        less,        greater ] };
    key <AA06>  { [  bracketleft,      braceleft,   ccedilla,         Ccedilla  ] };
    key <AA07>  { [  bracketright,     braceright                ] };

    include "level3(ralt_switch)"
};

partial alphanumeric_keys
xkb_symbols "deadtilde" {

    include "es(basic)"

    name[Group1]="Spanish (dead tilde)";

    key <AE04>  { [         4,     dollar,   dead_tilde,       dollar ] };
};

partial alphanumeric_keys
xkb_symbols "olpc2" {

    // Modified variant of US International layout, specifically for Peru
    // Contact: Sayamindu Dasgupta <[email protected]>

    include "us(olpc)"
    name[Group1]="Spanish (OLPC2)";

    key <AE03> { [  3, numbersign,   dead_grave,  dead_grave] }; // combining grave
    key <I236>  { [ XF86Start ] };

    include "level3(ralt_switch)"
};

// EXTRAS:

partial alphanumeric_keys
    xkb_symbols "sun_type6" {
    include "sun_vndr/es(sun_type6)"
};

The output of setxbkmap -query -verbose:

    $ setxkbmap -print -verbose
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+es+inet(evdev)+group(win_space_toggle)+eurosign(e)+terminate(ctrl_alt_bksp)
geometry:   pc(pc105)
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+es+inet(evdev)+group(win_space_toggle)+eurosign(e)+terminate(ctrl_alt_bksp)"    };
    xkb_geometry  { include "pc(pc105)" };
};

I can see that xkb applies a change to the eurosign. I suppose that change is made after reading the keyboard layout file (es) above. So the question is how I permanently stop xkb from making that change.

The change does not come from the keyboard configuration file:

$ cat /etc/default/keyboard 
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="es"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

I have also tried to use dconf-editor, as per this, but it only shows the options above, that is, no options. I have also tried:

sudo gsettings set org.gnome.desktop.input-sources xkb-options "['grp:win_space_toggle', 'terminate:ctrl_alt_bksp']"

No joy.

So what is going on? Help much appreciated...

Note: The locale is en-us, while the keyboard is es-es.

Andra avatar
tr flag
what is the output of `setxkbmap -query` before these changes?
ElToro1966 avatar
br flag
Outputs of setxkbmap -query added above.
ElToro1966 avatar
br flag
Ah. Now I get why the EuroSign is there. The options overwrite what's in the file, right? The ½ sign on AltGr-5 is still a mystery, though.
Andra avatar
tr flag
does this modification change anything at all? try `setxkbmap -print -verbose 10`
ElToro1966 avatar
br flag
@Andra, I have clarified the question. I made changes directly in the keyboard layout file (es) to make the changes I wanted. That worked on the old Ubuntu installation. Now, I see that xkb makes changes to the euro-sign through options. I suppose that happens after the keyboard layout has been read. I Thus, I guess that I have to stop xkb from making that change and everything would work. Thanks.
vanadium avatar
cn flag
Did you try disabling the keyboard option for the euro sign at the terminal using setxkbmap - perhaps your customizations will then work as expected
ElToro1966 avatar
br flag
@vanadium, that works! If I do $ sudo setxkbmap -option it gets rid of all previous options, and $ sudo setxkbmap -option eurosign:5 I get the euro-sign working on AltGr-5. However, this is not persistent through restarts. After restart, I get the result in the answer below. How do I make it permanent? Thanks.
vanadium avatar
cn flag
Should be /etc/default/keyboard, but it can be overridden also by Xorg (just like Gnome overrides it for the current user)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.