Skip to content

fix(hyprland): add keyboard layout switch command with multi-device sync - #14928

Closed
MahirIsHere wants to merge 1 commit into
omacom:quattrofrom
MahirIsHere:fix/hyprland-keyboard-layout-switch
Closed

MahirIsHere wants to merge 1 commit into
omacom:quattrofrom
MahirIsHere:fix/hyprland-keyboard-layout-switch

Conversation

@MahirIsHere

@MahirIsHere MahirIsHere commented Oct 10, 2026 •

Copy link
Copy Markdown

Summary

When Fcitx5 is running (enabled by default in Omarchy for IME support), it creates a virtual keyboard device (hl-virtual-keyboard-fcitx5), which claims the main: yes flag in Hyprland. As a result, standard layout switching commands like hyprctl switchxkblayout current next silently fail to cycle the physical keyboard.

Furthermore, Omarchy previously shipped no dedicated CLI helper to cycle keyboard layouts from scripts or keybindings.

Changes

  • Add bin/omarchy-hyprland-keyboard-layout-switch: Mirrors the multi-device synchronization logic in KeyboardLayout.qml (cycleLayout()). It identifies the primary typed keyboard, determines its next layout index, and switches all devices sharing that seat layout list to the same index in lockstep. This prevents devices from drifting apart and reliably cycles physical keyboards regardless of virtual devices or active layouts. Supports an optional [device] argument for targeted switching.
  • Add unit tests in test/shell.d/keyboard-layout-test.sh: Adds automated test coverage covering single-layout no-ops, multi-device lockstep synchronization, caller device selection, unknown device handling, and fallback behavior.
  • No intrusive default keybindings: Following feedback regarding binding collisions (such as SUPER + grave for scratchpad and SUPER + K for keybinding menus), this PR strictly provides the core CLI command, leaving keybinding customization to user configuration (~/.config/hypr/bindings.lua) or XKB toggle options.

Testing

  • Verified with omarchy commands --check (passes, 518 commands).
  • Verified with ./test/cli test suite (all tests pass).
  • Verified with ./test/shell.d/keyboard-layout-test.sh (all 41 tests pass).
  • Verified live layout toggling between multiple layouts on hardware.

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds a keyboard-layout helper that advances matching devices together.

  • A new command cycles layouts across keyboards with the same layout list.

Reviews (6) · Last reviewed commit: "fix(hyprland): add keyboard layout switc..." · Reviewed by Greptile

@jandrusk

Copy link
Copy Markdown

Useful companion for multi-layout setups, and the fcitx5 virtual-keyboard main note matches reports like #14892 / #15006.

Please double-check default binding collisions (SUPER + code:49 / SUPER + SHIFT + K) against existing utilities bindings and #12400’s Ctrl+Space request. This doesn’t by itself make input.lua persist a Norwegian layout — #14892 still needs the fcitx/hypr ownership fix.

@MahirIsHere
MahirIsHere force-pushed the fix/hyprland-keyboard-layout-switch branch from d11944d to 7105743 Compare October 12, 2026 19:19
@MahirIsHere MahirIsHere changed the title fix(hyprland): add keyboard layout switch command and default keybindings fix(hyprland): add keyboard layout switch command with multi-device sync Oct 12, 2026
@MahirIsHere

Copy link
Copy Markdown
Author

Thanks @jandrusk! Good catch on the binding collisions.

  1. Keybinding Collisions: You're completely right. SUPER + code:49 collided directly with SUPER + grave (special:scratchpad in tiling.lua), and SUPER + SHIFT + K encroached on the SUPER + ... + K keybinding cheatsheet menus in utilities.lua. As discussed in Default keyboard layout switch to Ctrl+Space #12400, choosing an opinionated default chord often fights with either desktop bindings or IDE shortcuts. I have removed the changes to utilities.lua so this PR strictly ships the omarchy-hyprland-keyboard-layout-switch command, leaving keybinding selection to user preferences in ~/.config/hypr/bindings.lua (or standard kb_options like grp:alt_shift_toggle).
  2. Keyboard Synchronization: I also updated the script to mirror KeyboardLayout.qml's cycleLayout() logic: it queries the primary typed keyboard, computes the next index, and synchronizes all input devices sharing that seat layout list to the same index in lockstep. This prevents multi-device drift and handles virtual devices cleanly.
  3. Changing keyboard layout to Norwegian ("no") in ~/.config/hypr/input.lua doesn't work #14892 / Keyboard layout chosen in installer isn't applied to Hyprland/fcitx5 — desktop falls back to US #15006: Agreed that the first-boot layout persistence / ownership is a separate install-time issue; this helper provides the reliable runtime cycling companion.

@MahirIsHere
MahirIsHere force-pushed the fix/hyprland-keyboard-layout-switch branch from 7105743 to 7413476 Compare October 12, 2026 20:08
@MahirIsHere
MahirIsHere force-pushed the fix/hyprland-keyboard-layout-switch branch from 7413476 to 2f72a07 Compare October 12, 2026 20:20
@MahirIsHere
MahirIsHere force-pushed the fix/hyprland-keyboard-layout-switch branch from 2f72a07 to fa59670 Compare October 12, 2026 20:30
@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this. What it does is now on quattro, so I am closing it.

quattro has omarchy-input-method cycle [back] on Super+I (and Super+Shift+I), which switches compositor layouts in step across keyboards and then Fcitx input methods.

This was checked against quattro by Claude, with Codex at medium effort verifying the claims above. If something here is still missing, say so and this can be reopened.

@omarchybot omarchybot closed this Oct 15, 2026
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.

3 participants