I want to set custom shortcut to change keyboard layout using setxkbmap. For example win_caps (Win+CapsLock). This option is not listed in /usr/share/X11/xkb/rules/base.lst

How can I achieve this?

  • 1
    You'll have to define your own custom option (example). – don_crissti Nov 23 '15 at 14:21
  • @don_crissti I haven't got a time to try to write it with all the grasp I could gather, but after a hour or so browsing through the Internet I still didn't get how to write custom grp toggle option. If you could at least give me a link to some kind of comprehensive xkb configuration guide I would greatly appreciate it. – ddnomad Nov 27 '15 at 23:35
up vote 3 down vote accepted

You'll have to define a custom option e.g. win_caps_toggle.
Add the following definition to your /usr/share/X11/xkb/symbols/group:

// toggle using win + capslock as combo
partial modifier_keys
xkb_symbols "win_caps_toggle" {
    key <CAPS> {
        type[Group1]="PC_SUPER_LEVEL2",
        symbols[Group1] = [ Caps_Lock, ISO_Next_Group ]
    };
};

and the following description to your usr/share/X11/xkb/rules/evdev.lst:

grp:win_caps_toggle Win+Caps Lock

anywhere under the grp section (e.g. under grp:caps_toggle).
You can then run

setxkbmap -option grp:win_caps_toggle

to set Win+CapsLock as the shortcut that changes the keyboard layout.


Note: this solution doesn't work with gnome 3. I think in order to make it work some stuff has to be disabled in gnome; I've tried disabling gnome-settings-daemon keyboard plugin and mutter overview key but no go. Works fine with other DE's though.

  • Thanks a lot! I'll try to implement this tomorrow, as I'll have time for it. And please, can you give me a link to some kind of docs that would explain the process of xkb configuration? – ddnomad Nov 30 '15 at 21:00
  • I think this doesn't work in gnome because gnome-shell implements differently the work with XKB. Sorry for not being more specific, I don't speak XKB. – Hi-Angel Oct 19 '16 at 13:45

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.

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