Here is a very detailed answer that helped me.
What I did to activate Ctrl + Space selector for keyboard layout →
- Add new selector
grp:lctrl_space_toggleline in/usr/share/X11/xkb/rules/evdev.lst:
! option
grp Switching to another layout
grp:switch Right Alt (while pressed)
grp:lswitch Left Alt (while pressed)
...
grp:lctrl_space_toggle Ctrl+Space (Custom layout selector)
...
- Add new selector
grp:lctrl_space_toggleline to/usr/share/X11/xkb/rules/evdev:
! option = symbols
grp:shift_toggle = +group(shifts_toggle)
altwin:menu = +altwin(menu)
altwin:menu_win = +altwin(menu_win)
...
grp:lctrl_space_toggle = +group(lctrl_space_toggle)
...
- Add the group block to
/usr/share/X11/xkb/symbols/group:
partial modifier_keys
xkb_symbols "lctrl_space_toggle" {
key <SPCE> {
type[Group1]="PC_CONTROL_LEVEL2",
symbols[Group1] = [ space, ISO_Next_Group ]
};
};
* I added this block between other grp: groups
- Get current keyboard options:
setxkbmap -print -verbose 10 | grep options:
Output (in my case):
options: ctrl:nocaps,grp:win_space_toggle
- Here is default
grp:win_space_togglewill override our parameter, so we should clear all options first:
setxkbmap -option
- Add new layout selector option + other options that was set before (except
grp:...one):
setxkbmap -option grp:lctrl_space_toggle,ctrl:nocaps
- Profit
PS it is possible that some GUI tools may override this behavior on reboot (System→Keyboard→Advanced feature in KDE did this stuff in my case), so we have to turn off any shortcut tweaks to avoid it.
Also it may be useful to add our custom parameters to /etc/default/keyboard:
...
XKBOPTIONS="grp:lctrl_space_toggle,ctrl:nocaps"
...