5

Ok, so I've been googling this for almost a week now...without any luck. When I open the Keyboard settings pane, the options are only limited to (ones that have "Space" in them) Alt+Space and Super+Space - there is no Ctrl+Space

I've found a couple of answers, non of which seem to work.

First one is to install the xfce4-xkb-plugin (which I already had installed), then set "use system default" flag in the Keyboard settings pane, after which use plugin Properties to set the languages and shortcuts. Doesn't work - the Properties pane only has options on how the pane item looks...that's it

Number two is this line:

-option grp:ctrl_space_toggle,grp_led:scroll en,ru

Doesn't work either. If I put this in my .Xmodmap file, there is an error and the file isn't parsed anymore.

I give up on searching, but I really need this, as it's a long time reflex. Please help me set Ctrl+Space as a shortcut to change layout. (I use Arch Linux if that makes any difference)

AReddy
  • 3,172
  • 5
  • 36
  • 76
simon
  • 171
  • Looks like xkb does not have a predefined group toggle for Ctrl+Space. You can probably define your own rule similarly to how it is done here https://unix.stackexchange.com/a/246491/49033 – Mike Jul 22 '19 at 20:01

1 Answers1

0

Here is a very detailed answer that helped me.

What I did to activate Ctrl + Space selector for keyboard layout →

  1. Add new selector grp:lctrl_space_toggle line 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)
  ...
  1. Add new selector grp:lctrl_space_toggle line 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)
  ...
  1. 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

  1. Get current keyboard options:
setxkbmap -print -verbose 10 | grep options:

Output (in my case):

options:    ctrl:nocaps,grp:win_space_toggle
  1. Here is default grp:win_space_toggle will override our parameter, so we should clear all options first:
setxkbmap -option
  1. Add new layout selector option + other options that was set before (except grp:... one):
setxkbmap -option grp:lctrl_space_toggle,ctrl:nocaps
  1. Profit

PS it is possible that some GUI tools may override this behavior on reboot (SystemKeyboardAdvanced 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"
...
rzlvmp
  • 101
  • Wow.. looks interesting! Now to remember that LUKS passphrase on a laptop with that Arch system... – simon Nov 14 '23 at 10:04