Skip to content

Add a keyboard layout switch command with an OSD readout - #6517

Open
kmpeeduwee wants to merge 1 commit into
basecamp:quattrofrom
kmpeeduwee:keyboard-layout-osd
Open

Add a keyboard layout switch command with an OSD readout#6517
kmpeeduwee wants to merge 1 commit into
basecamp:quattrofrom
kmpeeduwee:keyboard-layout-osd

Conversation

@kmpeeduwee

Copy link
Copy Markdown

Why

Volume, brightness, and media keys all answer through the OSD, but switching the keyboard layout answers with nothing: bind hyprctl switchxkblayout and the only way to find out which layout you landed on is to type something and see what comes out. With two layouts that means guessing wrong half the time; with more, worse.

What this adds

omarchy-hyprland-keyboard-layout [next|prev|status] — the same shape as omarchy-audio-output-volume: perform the change, then show the result on the OSD.

  • next / prev dispatch switchxkblayout all and pop the OSD with the keyboard glyph and the new layout's name as xkb reports it — "English (US)", "Portuguese (Brazil)", "German (dead acute)", whatever is configured.
  • status prints the active layout to stdout without switching or opening the OSD.

No default binding is added; users point whichever combo they already switch
with at it:

o.bind("SUPER + U", "Switch keyboard layout", "omarchy-hyprland-keyboard-layout", { locked = true })

locked = true is worth having here: the layout you type your lock-screen password in is the one place where being on the wrong one hurts most.

Notes

  • The layout is read back from the main keyboard rather than the first entry in hyprctl devices — power buttons and other keymap-less inputs also sit in keyboards, and all switches every real keyboard anyway, so the main one speaks for the lot.
  • hyprctl answers the dispatch only after the switch lands, so the read that follows already sees the new keymap; no polling or delay is needed.
  • The OSD already had a keyboard icon; no shell changes.

Tests

test/shell.d/keyboard-layout-test.sh stubs hyprctl and omarchy-osd and covers: the default action dispatching switchxkblayout all next and showing the main keyboard's layout, prev, status printing without switching or opening the OSD, and an unknown action exiting non-zero. The fixture puts a keymap-less non-main "keyboard" first to pin the main-keyboard selection, and its keymap name carries a space and parentheses — the shape xkb names come in — to prove the name reaches the OSD intact.

Verified on a running desktop: switching layouts shows the OSD with the layout name in the same spot the volume OSD uses.

Copilot AI review requested due to automatic review settings August 2, 2026 17:30

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

Adds a Hyprland keyboard-layout command with OSD feedback and status reporting.

Changes:

  • Adds next, previous, and status actions.
  • Adds shell tests for dispatching, OSD output, and invalid actions.

Tip

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

Reviewed changes

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

File Description
bin/omarchy-hyprland-keyboard-layout Implements layout switching and reporting.
test/shell.d/keyboard-layout-test.sh Tests command behavior and main-keyboard selection.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants