Short background

I'm trying to write my own keyboard layout with the super/mod4/win-key in place of caps lock. But no matter what caps lock is instead bound to ctrl.

I'm currently on a 64 bit Ubuntu 16.04 installation.

Long background

Given the following xkb symbols file located in ~/.config/xkb/symbols/qq:

partial default alphanumeric_keys
xkb_symbols "basic" {
include "latin(type2)"
include "se(se)"
};

partial alphanumeric_keys
xkb_symbols "se" {

name[Group1]="Sweden";

key <AE05> { [ 5, percent, EuroSign, cent ] };
key <AE11> { [ plus, question, backslash, questiondown ] };
key <AE12> { [dead_acute, dead_grave, plusminus, notsign ] };


key <AC10> { [odiaeresis, Odiaeresis, oslash, Ooblique ] };
key <AC11> { [adiaeresis, Adiaeresis, ae, AE ] };
key <TLDE> { [ section, onehalf, paragraph, threequarters] };

key <BKSL> { [apostrophe, asterisk, acute, multiply ] };

key <SPCE> { [ space, space, space, nobreakspace ] };

key <LSGT> { [ less, greater, bar, brokenbar ] };
include "kpdl(comma)"

include "level3(ralt_switch)"
};


// Swedish Dvorak A5
partial alphanumeric_keys
xkb_symbols "dvorak" {

name[Group1]="Sweden - Dvorak A5";

include "se(basic)"

key <AD01> { [ aring, Aring, braceleft ] };
key <AD02> { [ adiaeresis, Adiaeresis, braceright, bracketleft ] };
key <AD03> { [ odiaeresis, Odiaeresis, bracketleft, bracketright ] };
key <AD04> { [ p, P, bracketright, THORN ] };
key <AD05> { [ y, Y, dollar, yen ] };
key <AD06> { [ f, F, quotedbl, ordfeminine ] };
key <AD07> { [ g, G, question, ENG ] };
key <AD08> { [ c, C, ampersand, copyright ] };
key <AD09> { [ r, R, less, registered ] };
key <AD10> { [ l, L, greater, Lstroke ] };
key <AD11> { [ comma, semicolon, dead_tilde, dead_ogonek ] };
key <AD12> { [ dead_diaeresis, dead_circumflex, dead_tilde, asciicircum ] };

key <AC01> { [ a, A, semicolon, AE ] };
key <AC02> { [ o, O, slash, OE ] };
key <AC03> { [ e, E, parenleft, cent ] };
key <AC04> { [ u, U, parenright, uparrow ] };
key <AC05> { [ i, I, bar, idotless ] };
key <AC06> { [ d, D, numbersign, ETH ] };
key <AC07> { [ h, H, asciicircum, Hstroke ] };
key <AC08> { [ t, T, quotedbl, Tslash ] };
key <AC09> { [ n, N, asciitilde ] };
key <AC10> { [ s, S, ssharp, section ] };
key <AC11> { [ minus, underscore, dead_belowdot, dead_abovedot ] };

key <AB01> { [ period, colon, bar, dead_abovedot ] };
key <AB02> { [ q, Q, equal, Greek_OMEGA ] };
key <AB03> { [ j, J, at ] };
key <AB04> { [ k, K, exclam, ampersand ] };
key <AB05> { [ x, X, backslash, greater ] };
key <AB06> { [ b, B, percent, apostrophe ] };
key <AB07> { [ m, M, grave, masculine ] };
key <AB08> { [ w, W, lstroke, Lstroke ] };
key <AB09> { [ v, V, leftdoublequotemark, grave ] };
key <AB10> { [ z, Z, guillemotleft, less ] };


// Make the < to the lower left part of the keyboard a ctrl key.
replace key <LSGT> { [ Control_L, Control_L ] };
modifier_map Control { <LCTL>, <LSGT> };

// Make caps lock into a super/windows key.
replace key <CAPS> { [ Super_L, Super_L ] };
modifier_map Mod4  { <CAPS>, <LWIN>};

};

The following attempt at setting the keyboard layout fails:

$ setxkbmap -I ~/.config/xkb qq dvorak -print | xkbcomp -I$HOME/.config/xkb - $DISPLAY
...
Error:            Key <CAPS> added to map for multiple modifiers
                  Using Control, ignoring Mod4.
...

But as you can see in the given configuration, no such modifier_map is given, a modifier_map is given for Control but it only does not contain .

Looking further into the issue I see that setxkbmap always contains this option:

$ setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     se
variant:    dvorak
options:    caps:super_modifier,caps:ctrl_modifier
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+se(dvorak)+inet(evdev)+capslock(ctrl_modifier)
geometry:   pc(pc105)
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"  };
    xkb_compat    { include "complete"  };
    xkb_symbols   { include "pc+se(dvorak)+inet(evdev)+capslock(ctrl_modifier)" };
    xkb_geometry  { include "pc(pc105)" };
};

Which is really strange given that we've never supplied such an option.

Question

Why is this option always included in every invocation of setxkbmap?

Hotfix

It is possible to pass -option without any argument to setxkbmap to clear any default options.

setxkbmap -I ~/.config/xkb qq dvorak -option -print | xkbcomp -I$HOME/.config/xkb - $DISPLAY
  • note the file you post includes symbols from other files (include "se(whatever)") -- this means load stanza "whatever" from file se, which is probably the system xkb file /usr/share/X11/xkb/symbols/se. if you intend these to be loaded from your modified file instead, replace them with "qq(whatever)". (i'm not sure this has anything to do with your extra capslock option.) – quixotic Jan 11 at 17:45
  • as you've noted in your "hotfix", setxkbmap -option clears any existing options. you don't show us what your XKB settings are just after you log in, but presumably something is setting that option early. if you are on GNOME, perhaps the keyboard settings daemon is active and reapplying the odd setting. if it's not being reapplied by a settings daemon, you can use arguments to setxkbmap to clear the unwanted options before setting new ones like so: setxkbmap -option -option opt:opt1,opt:opt2 – quixotic Jan 11 at 17:49
  • (this is just how setxkbmap works -- it adds options to existing ones and requires an explicit -option to clear the list. see man setxkbmap) – quixotic Jan 11 at 17:51
  • Thank you for your kind hints @quixotic! I've modified my file to include from qq(whatever), just as you thought this was what I actually wanted. I'm using Awesome so there shouldn't be anything setting xkbmap options without me doing it, but thank you for explaining that setxkbmap transforms the current state of the options array rather than resetting it. – Rovanion Jan 12 at 13:11

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.