omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Keyboard layout widget switches Logitech G502 instead of physical keyboard

Open szalikdev opened this issue 2 months ago • 3 comments

Description

The omarchy.keyboard-layout bar widget can select a mouse-provided keyboard interface instead of the physical typing keyboard. The indicator then changes to the requested layout, but typed characters continue using the previous layout.

In this case, selecting German made the bar show DE, while the real keyboard continued producing the Polish layout.

Steps to reproduce

  1. Connect a Logitech G502 LIGHTSPEED mouse and a USB keyboard.
  2. Configure two layouts in Hyprland: kb_layout = "pl,de" and kb_variant = ",".
  3. Click the keyboard-layout widget to switch from Polish to German.
  4. Type Y and Z.

Actual behavior

The bar shows German, but the physical keyboard remains Polish. Live hyprctl -j devices state showed:

logitech-g502:                 active_layout_index 1, German
sonix-usb-device:              active_layout_index 0, Polish
sonix-usb-device-keyboard:     active_layout_index 0, Polish
hl-virtual-keyboard-fcitx5:    active_layout_index 0, Polish

KeyboardLayoutModel.isTypedKeyboard() treats logitech-g502 as a typing keyboard because UNTYPED_KEYBOARDS only excludes known virtual and ACPI-style names. Since selectKeyboard() selects the furthest-advanced eligible device, the widget remains attached to the G502 after switching it.

Expected behavior

The widget should select and switch a keyboard that receives normal text input, ignoring keyboard-like interfaces exposed by mice and similar peripherals.

Confirmed workaround

Cloning omarchy.keyboard-layout and adding logitech-g502$ to UNTYPED_KEYBOARDS makes the widget select sonix-usb-device; Polish/German switching then targets the physical keyboard correctly.

A device-specific exclusion proves the cause, although a generic way to distinguish typing keyboards would be preferable upstream.

System information

  • Omarchy: 4.0.2-1
  • Hyprland: 0.56.2-1
  • Kernel: 7.1.9-arch1-2
  • CPU/GPU: AMD Ryzen Embedded R1505G / Radeon Vega
  • Mouse: Logitech G502 LIGHTSPEED
  • Keyboard interfaces: sonix-usb-device, sonix-usb-device-keyboard
  • Input method: fcitx5 5.1.21-1

Diagnostics were collected with omarchy-debug --no-sudo --print; there were no keyboard-related warnings.

szalikdev avatar Sep 04 '26 07:09 szalikdev

I checked the related keyboard-selection work in #9129 (for #8964). It changes the same UNTYPED_KEYBOARDS filter to exclude names ending in -wmi-hotkeys or -wireless-radio-control, including numbered duplicates.

I evaluated that proposed regular expression against the device names here: logitech-g502 and sonix-usb-device both remain eligible, while acer-wmi-hotkeys is excluded. So #9129 is related work in the same filter, but it does not cover the G502 case as currently written. Linking it for coordination and to keep that distinction explicit. I have not independently reproduced this on G502 hardware.

CompleteDotTech avatar Sep 05 '26 04:09 CompleteDotTech

I reproduced this on Omarchy 4.0.3-1.

My configuration uses:

kb_layout = "us,br"

The device named logitech-usb-receiver is my Logitech mouse/receiver, not a keyboard. However, Hyprland exposes it in the keyboard device list, and the omarchy.keyboard-layout widget selects it.

Before unplugging the mouse, the device states were:

logitech-usb-receiver          Portuguese (Brazil)
at-translated-set-2-keyboard   English (US)
tuxedo-keyboard                English (US)

Clicking the top-bar widget runs the equivalent of:

hyprctl switchxkblayout logitech-usb-receiver next

The top-bar label changes, but the actual keyboard remains in US.

After unplugging the Logitech mouse/receiver, the widget cycles correctly between the real keyboards.

The widget should filter out this mouse/receiver device instead of treating every device exposed in the keyboard list as a usable keyboard.

killer-cf avatar Sep 08 '26 22:09 killer-cf

This is fixed on quattro by #10670 (6ee747987, merged 2026-09-07), but the fix is not in a release yet: v4.0.2, v4.0.3 and v4.0.4 are cut from release branches and all three still run hyprctl switchxkblayout <one device> next on the single keyboard the widget picked (shell/plugins/bar/widgets/KeyboardLayout.qml:76 in those tags). That is the behaviour both of you saw: the G502 or the Logitech receiver passes the UNTYPED_KEYBOARDS name filter, gets picked, and is the only device that moves.

On quattro a click no longer depends on which device is picked. cycleLayout() (KeyboardLayout.qml:94) sends the same absolute layout index to every keyboard holding the seat's layout list (syncNames, built at line 179), so logitech-g502, sonix-usb-device, sonix-usb-device-keyboard and the fcitx5 virtual keyboard all move together, and the label reads the same keymap whichever of them it settles on. A seat that has already drifted apart, like the state in the report, converges on the first click, so that click may land on the layout you were already typing in; after it, clicks move everything together. The mouse is still not excluded by name, but it no longer matters unless it carries a different kb_layout of its own, which nothing in either report suggests.

How it was checked: by reading the widget at quattro head d74d6ea24 against the released versions. Nothing was run, since the symptom needs the mouse hardware. Codex Medium reviewed it independently and reached the same conclusion; it added the point about the first click on a drifted seat. Its independence is not guaranteed.

Related: #6833 (an Apple headset on T2 Macs) and #8964 (vendor WMI hotkey devices) are the same mechanism with other devices, and #10883 is a laptop plus an external keyboard; #10670 addresses all of them in the same way.

Next: this waits on the maintainer to decide whether to close it as fixed by #10670 now or once it ships. If you run a build from quattro before then, a note saying whether the G502 still gets in the way would settle it.

omarchybot avatar Oct 11 '26 04:10 omarchybot