16

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?

2
  • 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
    Commented Feb 27, 2014 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
    Commented May 10, 2014 at 6:39

1 Answer 1

15

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):

1
  • 1
    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
    Commented May 10, 2014 at 7:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .