4

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?

don_crissti
  • 82,805
ddnomad
  • 1,978
  • 2
  • 16
  • 31
  • 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

1 Answers1

7

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.

don_crissti
  • 82,805