You are not logged in.

#1 2021-07-19 14:23:31

TheCoon
Member
Registered: 2016-05-10
Posts: 42

Switch keyboard layout using hotkey not offered by xkeyboard-config

xkeyboard-config lists several different options for defining the keyboard combination to switch layout.

http://manpages.org/xkeyboard-config#options

   ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────┐
   │Option                      Description                                                                    │
   ├───────────────────────────────────────────────────────────────────────────────────────────────────────────┤
   │grp:switch                  Right Alt (while pressed)                                                      │
   │grp:lswitch                 Left Alt (while pressed)                                                       │
   │grp:lwin_switch             Left Win (while pressed)                                                       │
   │grp:rwin_switch             Right Win (while pressed)                                                      │
   │grp:win_switch              Any Win key (while pressed)                                                    │
   │grp:caps_switch             Caps Lock (while pressed), Alt+Caps Lock does the original capslock action     │
   │grp:rctrl_switch            Right Ctrl (while pressed)                                                     │
   │grp:toggle                  Right Alt                                                                      │
   │grp:lalt_toggle             Left Alt                                                                       │
   │grp:caps_toggle             Caps Lock                                                                      │
   │grp:shift_caps_toggle       Shift+Caps Lock                                                                │
   │grp:shift_caps_switch       Caps Lock (to first layout), Shift+Caps Lock (to last layout)                  │
   │grp:win_menu_switch         Left Win (to first layout), Right Win/Menu (to last layout)                    │
   │grp:lctrl_rctrl_switch      Left Ctrl (to first layout), Right Ctrl (to last layout)                       │
   │grp:alt_caps_toggle         Alt+Caps Lock                                                                  │
   │grp:shifts_toggle           Both Shift keys together                                                       │
   │grp:alts_toggle             Both Alt keys together                                                         │
   │grp:ctrls_toggle            Both Ctrl keys together                                                        │
   │grp:ctrl_shift_toggle       Ctrl+Shift                                                                     │
   │grp:lctrl_lshift_toggle     Left Ctrl+Left Shift                                                           │
   │grp:rctrl_rshift_toggle     Right Ctrl+Right Shift                                                         │
   │grp:ctrl_alt_toggle         Alt+Ctrl                                                                       │
   │grp:alt_shift_toggle        Alt+Shift                                                                      │
   │grp:lalt_lshift_toggle      Left Alt+Left Shift                                                            │
   │grp:alt_space_toggle        Alt+Space                                                                      │
   │grp:menu_toggle             Menu                                                                           │
   │grp:lwin_toggle             Left Win                                                                       │
   │grp:rwin_toggle             Right Win                                                                      │
   │grp:lshift_toggle           Left Shift                                                                     │
   │grp:rshift_toggle           Right Shift                                                                    │
   │grp:lctrl_toggle            Left Ctrl                                                                      │
   │grp:rctrl_toggle            Right Ctrl                                                                     │
   │grp:sclk_toggle             Scroll Lock                                                                    │
   │grp:lctrl_lwin_rctrl_menu   LeftCtrl+LeftWin (to first layout), RightCtrl+Menu (to second layout)          │
   │                                                                                                           │
   └───────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Currently I use: grp:alt_shift_toggle

I would like to use the Ctrl+Space combination, but this option isn't available in the list.
Is there a way to get Ctrl+Space to work?

Last edited by TheCoon (2021-07-19 14:24:54)

Offline

#2 2021-07-19 14:29:53

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,432

Re: Switch keyboard layout using hotkey not offered by xkeyboard-config

xdotool key ISO_Next_Group

Offline

#3 2021-07-19 15:31:09

TheCoon
Member
Registered: 2016-05-10
Posts: 42

Re: Switch keyboard layout using hotkey not offered by xkeyboard-config

seth wrote:
xdotool key ISO_Next_Group

Thank you, I should have mentioned in the first post that I am using Sway WM, and this is how I set the keyboard layout and hotkey settings:

input * {
    xkb_layout "us,fr"
    xkb_options "grp:alt_shift_toggle"
    xkb_numlock enable
}

Offline

#4 2021-07-19 15:35:13

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,432

Re: Switch keyboard layout using hotkey not offered by xkeyboard-config

Offline

#5 2021-07-19 15:54:29

TheCoon
Member
Registered: 2016-05-10
Posts: 42

Re: Switch keyboard layout using hotkey not offered by xkeyboard-config

I tried using ydotool, but it seems like it requires root permissions. This was the output using sudo:

ydotool: notice: unable to access ydotoold backend: failed to connect to socket: No such file or directory
ydotool: you may experience device recognition delay issues
Next delay was set to 50 milliseconds.
Key delay was set to 12 milliseconds.
Repeat was set to 1 times.
Repeat delay was set to 20 milliseconds.

I found the following GitHub comment which suggests a possible solution (adding my user to the input group, adding a udev rule, and running ydotool on boot):
https://github.com/ReimuNotMoe/ydotool/ … -624629221

This seems like a rather complex solution to a somewhat simple problem. Is there really no other way?

Last edited by TheCoon (2021-07-19 15:55:36)

Offline

#6 2021-07-19 16:13:28

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 77,432

Re: Switch keyboard layout using hotkey not offered by xkeyboard-config

Unlikely.
You could try to extend the xkb rules, just
1. there's no guarantee that any wayland implementation will pick that up
2. that's not less complicated at all

Offline

#7 2021-07-19 16:45:51

TheCoon
Member
Registered: 2016-05-10
Posts: 42

Re: Switch keyboard layout using hotkey not offered by xkeyboard-config

Got it. Thanks for offering an alternative. I'll try it out and see if it works well.

Offline

Board footer

Powered by FluxBB