Remapping both Caps Lock and Shift+Caps Lock in xkb

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?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

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


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x