I have two xkb layouts, and use Alt+Shift to toggle between them:

setxkbmap "fr,us" -option grp:alt_shift_toggle

However, when I press a shorcut which contains Alt+Shift, the shortcut isn't taken into account, and instead the layout switches. For example Alt+Shift+Left (which selects code to the matching closing paren in some editors), or Alt+Shift+% (which is search and replace in emacs, the % needing Shift on French keyboards).

This was not the case with XUbuntu 14.04 I think, but I switched to NixOs, and I now have this issue.

How can I configure setxkbmap so that it switches layouts only when Alt+Shift is not part of a shortcut, i.e. upon releasing the keys and only if there wasn't another key pressed at the same time?

1 Answer 1


This is a known limitation in xkb. sxhkd would be a better solution and gives you better control.

Add this to sxhkdrc:

Shift_L + Alt_L
    setxkbmap -query | grep -q 'fr' && setxkbmap us || setxkbmap fr,us
Shift_R + Alt_R
    setxkbmap -query | grep -q 'fr' && setxkbmap us || setxkbmap fr,us

Note that for some reason, alt must be pressed before shift to be detected by sxhkd.

You must log in to answer this question.

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