5

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

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

The 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.  It doesn't work – the Properties pane has only 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

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

I gave 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.)

1
  • 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 unix.stackexchange.com/a/246491/49033
    – Mike
    Commented Jul 22, 2019 at 20:01

1 Answer 1

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"
...
2
  • Wow.. looks interesting! Now to remember that LUKS passphrase on a laptop with that Arch system...
    – simon
    Commented Nov 14, 2023 at 10:04
  • It wasn’t the passphrase. My ssd got kaput. I can still decrypt my files, but the system would not boot anymore. If I ever get back to my arch system, I might try this suggestion out.
    – simon
    Commented yesterday

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .