Skip to content

Fix KeyboardLayout plugin label permanently displaying ENG on some systems - #6646

Merged
dhh merged 5 commits into
omacom:quattrofrom
artfwo:fix-keyboard-layout-active-keymap
Aug 9, 2026
Merged

dhh merged 5 commits into
omacom:quattrofrom
artfwo:fix-keyboard-layout-active-keymap

Conversation

@artfwo

@artfwo artfwo commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #6574

Keyboard layout bar widget polls the current keyboard layout with a regex/sed combo from the output of hyprctl -j devices. The list includes every input device that libinput/evdev exposes with the EV_KEY capability, e.g. power button and multimedia keys.

In my case, on Framework 13 Pro, the first occurrence of active_keymap is found under keyboard device frmw0004:00-32ac:0006-wireless-radio-control - a device that never receives the toggle and stays permanently in English (US) layout, causing the plugin to permanently display "ENG" regardless of the actual keyboard layout.

"keyboards": [
    {
        "address": "0x55b9740bae40",
        "name": "frmw0004:00-32ac:0006-wireless-radio-control",
        "rules": "",
        "model": "",
        "layout": "us,ru",
        "variant": "",
        "options": "compose:caps,shift:both_capslock_cancel,grp:alts_toggle",
        "active_layout_index": 0,
        "active_keymap": "English (US)",
        "capsLock": false,
        "numLock": true,
        "main": false
    }, 
    ....
],

This PR replaces the regex/sed scrape of hyprctl -j devices with proper JSON parsing that picks the keyboard flagged main: true, which seems to correctly track whichever device's layout is actually switched.

Copilot AI balanced review requested due to automatic review settings August 8, 2026 23:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes #6574 by selecting Hyprland’s main keyboard when displaying the active layout.

Changes:

  • Parses hyprctl output as JSON.
  • Uses the keyboard marked main instead of the first reported device.

Tip

If you aren't ready for review, convert to a draft PR. Click "Convert to draft" or run gh pr ready --undo.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@artfwo artfwo changed the title Fix KeyboardLayout plugin label permanently displaying ENG Fix KeyboardLayout plugin label permanently displaying ENG on some systems Aug 8, 2026
dhh and others added 2 commits August 9, 2026 04:56
find(k => k.main) returning nothing fell through to keyboards[0], which is
the case the fix is for: on hardware whose first device is a permanently
English (US) radio-control keyboard, the label was wrong and the 10s poll
kept it wrong. The seat can also hold no active keyboard while a device is
re-added, and older Hyprland has no main field at all. Keep the last known
value instead, and skip entries without an active_keymap, since assigning
undefined to the string property throws before the label is ever set.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
The shell wrapper only existed for a pipeline that is gone, so spawn the
command directly, as Style.qml already does for its own hyprctl query.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 9, 2026 11:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Every Omarchy install runs fcitx5 for ~/.XCompose, and it binds a virtual
keyboard that takes the seat's main flag whenever it injects. That keyboard
keeps the us layout the input method gave it, so on a machine configured for
another layout the widget flipped to ENG and the poll kept it there until the
next physical keypress. Skip virtual keyboards and hold the last known layout
instead, which the next poll corrects once a real keyboard is active again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 9, 2026 12:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Suppressed comments (1)

shell/plugins/bar/widgets/KeyboardLayout.qml:23

  • This predicate cannot handle the fcitx5 case described immediately above it: once hl-virtual-keyboard owns the seat's main flag, no non-virtual keyboard satisfies both conditions, so the later .find(...) returns undefined and the widget keeps a stale label. The prefix also identifies Hyprland virtual keyboards generally, not only fcitx5, so virtual-keyboard-only setups lose the label entirely. Select/remember the physical device associated with activelayout events, while retaining the main virtual keyboard as a fallback when no physical candidate exists.
    return kb.main && !String(kb.name).startsWith("hl-virtual-keyboard")

Holding a frozen label while fcitx5 owns the main flag went stale as soon as
the layout changed underneath it, and cycling still dispatched against
"current", which is that same virtual keyboard. Remember the keyboard the
label came from, re-read its layout on every poll, and cycle it by name so
the widget shows and switches one device.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Copilot AI review requested due to automatic review settings August 9, 2026 12:38

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@dhh
dhh merged commit 9d61915 into omacom:quattro Aug 9, 2026
@artfwo
artfwo deleted the fix-keyboard-layout-active-keymap branch August 11, 2026 10:15
nick1udwig pushed a commit to nick1udwig/omarchy that referenced this pull request Sep 9, 2026
…stems (omacom#6646)

* Fix hyprctl output parsing in KeyboardLayout plugin

* Never fall back to a non-active keyboard for the layout label

find(k => k.main) returning nothing fell through to keyboards[0], which is
the case the fix is for: on hardware whose first device is a permanently
English (US) radio-control keyboard, the label was wrong and the 10s poll
kept it wrong. The seat can also hold no active keyboard while a device is
re-added, and older Hyprland has no main field at all. Keep the last known
value instead, and skip entries without an active_keymap, since assigning
undefined to the string property throws before the label is ever set.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Run hyprctl directly from the keyboard layout widget

The shell wrapper only existed for a pipeline that is gone, so spawn the
command directly, as Style.qml already does for its own hyprctl query.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Read the layout from the keyboard the user types on

Every Omarchy install runs fcitx5 for ~/.XCompose, and it binds a virtual
keyboard that takes the seat's main flag whenever it injects. That keyboard
keeps the us layout the input method gave it, so on a machine configured for
another layout the widget flipped to ENG and the poll kept it there until the
next physical keypress. Skip virtual keyboards and hold the last known layout
instead, which the next poll corrects once a real keyboard is active again.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

* Keep tracking the keyboard the layout was last read from

Holding a frozen label while fcitx5 owns the main flag went stale as soon as
the layout changed underneath it, and cycling still dispatched against
"current", which is that same virtual keyboard. Remember the keyboard the
label came from, re-read its layout on every poll, and cycle it by name so
the widget shows and switches one device.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>

---------

Co-authored-by: David Heinemeier Hansson <[email protected]>
Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Issue with the omarchy.keyboard-layout plugin not visually switching layout

3 participants