Skip to content

Cinnamon 6.6 forces the XKB group back to 0, so no keyboard layout switching works #13904

Description

@EdgarSedov

What happens

I set up three layouts (us, jp, ru) on Mint 22.3. They load fine — setxkbmap -query
shows us,jp,ru, and all three groups are in the keymap with the right symbols.

But switching never works. Super+Space, Alt+Shift, grp:win_space_toggle,
ISO_Next_Group — none of them do anything.

The reason is that something forces the XKB group back to 0 almost immediately.

How to reproduce

No keyboard involved. Just lock the group and watch it:

#!/usr/bin/env python3
import ctypes, time

class St(ctypes.Structure):
    _fields_ = [("group", ctypes.c_ubyte), ("locked_group", ctypes.c_ubyte),
                ("base_group", ctypes.c_ushort), ("latched_group", ctypes.c_ushort),
                ("mods", ctypes.c_ubyte), ("base_mods", ctypes.c_ubyte),
                ("latched_mods", ctypes.c_ubyte), ("locked_mods", ctypes.c_ubyte),
                ("compat_state", ctypes.c_ubyte), ("grab_mods", ctypes.c_ubyte),
                ("compat_grab_mods", ctypes.c_ubyte), ("lookup_mods", ctypes.c_ubyte),
                ("compat_lookup_mods", ctypes.c_ubyte), ("ptr_buttons", ctypes.c_ushort)]

X = ctypes.CDLL("libX11.so.6")
X.XOpenDisplay.restype = ctypes.c_void_p
d = X.XOpenDisplay(None)
maj, min_ = ctypes.c_int(1), ctypes.c_int(0)
o, e, r = ctypes.c_int(), ctypes.c_int(), ctypes.c_int()
X.XkbQueryExtension(ctypes.c_void_p(d), ctypes.byref(o), ctypes.byref(e),
                    ctypes.byref(r), ctypes.byref(maj), ctypes.byref(min_))

def group():
    s = St()
    X.XkbGetState(ctypes.c_void_p(d), 0x0100, ctypes.byref(s))
    return s.group

X.XkbLockGroup(ctypes.c_void_p(d), 0x0100, 1)
X.XFlush(ctypes.c_void_p(d))
for t in (0.0, 0.05, 0.2, 1.0):
    time.sleep(t)
    print(f"{int(t*1000)}ms group={group()}")

Set up any two or more layouts first, then run it. I get:

0ms group=1
50ms group=0
200ms group=0
1000ms group=0

The group does change. Then it snaps back inside 50ms. Every time.

What I ruled out

  • ibus — still happens with zero ibus processes running (pgrep -c -f ibus returns 0)
  • csd-keyboard — killed it, no change. There's also no
    org.cinnamon.settings-daemon.plugins.keyboard schema to disable it properly
  • the keyboard panel applet — removed keyboard@cinnamon.org from
    enabled-applets, no change
  • org.gnome.desktop.input-sources current — setting it to 1 or 2 doesn't
    move the group
  • per-device keymaps — checked all 10 XI2 keyboard devices with
    setxkbmap -device N -query, every one reports us,jp,ru

The keymap itself is correct: num_groups=3, group names come back as
English (US) / Japanese / Russian.

Two other things that might be the same bug

1. Custom keybindings often don't register. I set one through gsettings
(custom-list + custom-keybinding schema), ran cinnamon --replace, and it
still didn't fire. Once it worked on the fourth binding I tried, then stopped
working after I changed it again. Rewriting the binding seems to break
re-registration.

2. No Super/Mod4 binding reaches an X client at all. Tested with xbindkeys:
control+alt+k, shift+alt+space, control+shift+space and Scroll_Lock all
fire. Every Mod4 combination does nothing — Mod4+space, Mod4+z, both dead.
This might be the Super key conflict from #13407.

Workaround

Skip XKB groups. Apply one layout at a time:

setxkbmap -model jp106 -layout jp

That sticks fine. I bound a small cycling script to Ctrl+Shift+Space with
xbindkeys, since Cinnamon's own keybindings didn't work. Downside is the panel
indicator no longer shows the layout, because that's driven by the same
subsystem.

Environment

Linux Mint 22.3 Zena
Cinnamon 6.6.9
X11 (not Wayland)
Kernel 7.0.0-28-generic
ibus 1.5.29-rc2
Laptop: MSI Stealth A16 AI+ (JIS keyboard, XKBMODEL=jp106)

Layout config in use:

XKBMODEL="jp106"
XKBLAYOUT="us,jp,ru"
XKBVARIANT=",,"
XKBOPTIONS="grp:win_space_toggle,terminate:ctrl_alt_bksp"

Also present in /etc/X11/xorg.conf.d/00-keyboard.conf (that file doesn't exist
by default on Mint — I had to create it, since localectl set-x11-keymap is
disabled on Debian/Ubuntu).

Related

#13407, #13397, #13513, #13280 — all describe layout switching failing in 6.6.
I think those are symptoms and this group reset is the cause, but I can't tell
from outside.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions