Any way to configure xkeyboard-config to only consider its own shortcut?

Hello,

I recently learned about setxkbmap to switch keyboard layouts, and I have the following line in my ~/.i3/config file to be able to change layouts using Left Alt + Left Shift

exec setxkbmap -layout us,ir -option 'grp:lalt_lshift_toggle'

However, I noticed something very inconvenient! I use a shortcut in my terminal that's set to Alt + Shift + w (more specifically it's for tmux and I have

bind-key -n M-W new-window ...

So, when I want to press Alt + Shift + w to use my tmux shortcut, the one set for xkeyboard-config is taking over and changing my keyboard layout, and because my other layout doesn't use English alphabet, it prevents me from using my shortcut.

So, I was wondering if there's a way to "force" the keyboard layout to change only when I press Alt + Shift and configure it so that it doesn't interfere with shortcuts that are somehow a "superset" of the configured key combination?

Thank you,
Farzad

The system will always execute the first command attached to a shortcut/combination key, has no awareness of your intentional next key press in combination with that. In short, you can use instead:
exec setxkbmap -layout us,ir -option 'grp:ctrl_shift_toggle'
or other combination that doesn't interfere when used for other combination command.

1 Like

I thought about the same thing, but I would consider that more of a workaround rather than a solution, but yeah, I think if the underlying system doesn't support it, then there's no solution.

I just wanted it to be consistent with the way I use Windows, so that I can use "muscle memory" to change layouts.

Now you will have two muscle groups :slight_smile:

1 Like

Yeah, I think I need to go more to the gym to improve my muscles :wink:

Memory muscles ?

Good catch :stuck_out_tongue_winking_eye: . I think I need to something else :smiley: