14

I am trying to configure xkb such that Caps Lock is mapped to the Compose key and Shift+Caps Lock functions as the traditional Caps Lock. I put the following in a new file called /usr/share/X11/xkb/symbols/gdwatson:

partial modifier keys
xkb_symbols "compose" {
    key <CAPS> {
        type[Group1] = "TWO_LEVEL",
        symbols[Group1] = [ Multi_key, Caps_Lock ]
    };
};

Then I ran setxkbmap -symbols 'pc+us+gdwatson(compose)', which completed successfully. Caps Lock works as Compose, but Shift+Caps Lock works as Compose instead of Caps Lock. xkbcomp :0.0 reveals the following:

key <CAPS> {
    type= "TWO_LEVEL",
    symbols[Group1]= [       Multi_key,       Multi_key ]
};

The second level symbol mapping is duplicating the first for some reason, rather than the separate value I tried to give it. Does anyone have strong enough xkb-fu to tell me what I've done wrong or how to fix it?

  • 1
    I can help you doing this in Xmodmap, but not xkb. If you want this, respond positively (do not forget to write @mirabilos in your response so I notice it) in a comment, then I will delete this comment and write it as an answer (you should then also delete your comment response). – mirabilos Feb 27 '14 at 21:28
  • 1
    On your first line, should partial modifier keys actually be partial modifier_keys? Without this change, setxkbmap -symbols 'pc+us+gdwatson(compose)' actually exits with an error, but with the change, I get the desired output from xkbcomp :0.0. However I get the undesired side-effect that pressing Capslock simultaneously puts me in Capslock mode and compose key mode. – billyjmc May 10 '14 at 6:39
10

This seems to accomplish what you're looking for.

partial modifier_keys
xkb_symbols "compose" {
    key <CAPS> {
        type[Group1] = "TWO_LEVEL",
        symbols[Group1] = [ Multi_key, Caps_Lock ],
        actions[Group1] = [ NoAction(), LockMods(modifiers=Lock) ]
    };
};

The following resources are invaluable when dealing with XKB (I've linked to the WayBack Machine's mirrors of these pages for future-proofing):

  • Also, if you make the first line default partial modifier_keys, then you don't have to explicitly specify setxkbmap -symbols 'pc+us+gdwatson(compose)', you can simply do setxkbmap -symbols 'pc+us+gdwatson' – billyjmc May 10 '14 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.