Skip to content

fix(menu): show Mac F-key names for brightness keys in keybindings menu - #215

Merged
malik-na merged 4 commits into
omacom:quattrofrom
sambai-dev:fix/menu-fkey-names
Aug 29, 2026
Merged

malik-na merged 4 commits into
omacom:quattrofrom
sambai-dev:fix/menu-fkey-names

Conversation

@sambai-dev

Copy link
Copy Markdown

Problem

The keybindings menu shows XKB symbol names instead of the physical Mac keys they represent. On Apple Silicon MacBook keyboards, XF86MonBrightnessUp/XF86MonBrightnessDown are emitted by the F2/F1 keys, so users see rows like SHIFT + XF86MonBrightnessUp even though the repo's own comments describe these binds as "SHIFT+F1/F2" (default/hypr/bindings/media.lua). That is exactly the gap reported in #194: Omarchy Mac specific keybindings missing from the menu "with proper names".

Approach

Extend the existing key-name mapping in bin/omarchy-menu-keybindings (the same case that already maps comma→COMMA, period→PERIOD, etc.):

  • XF86MonBrightnessUp → F2
  • XF86MonBrightnessDown → F1

Menu rows now render as SHIFT + F2 → Keyboard brightness up and ALT + F1 → Brightness down precise. All other bindings, including non-Mac keyboards where those symbols may come from real brightness keys, keep working; only the display name changes.

Alternatives considered: renaming the keys inside Hyprland config (would change bind matching, not just display), or special-casing descriptions (descriptions already exist and are fine). The menu script is the single display surface, so it is the right place.

Testing

  • New regression test test/shell.d/menu-keybindings-fkeys-test.sh: stubs hyprctl binds with the exact SHIFT+F1/F2 and ALT-precise records plus an unrelated SUPER+Q bind, runs omarchy-menu-keybindings --print, and asserts the F-key rendering, the untouched neighbor row, and no raw XF86MonBrightness leak.
  • Verified RED on unfixed code and GREEN with the fix; a sabotage run (fix reverted) fails the test as expected.
  • bash -n clean on changed scripts. Full ./test/all: 97 of 194 shell test
    files fail on this Windows dev host; verified via a pristine worktree at the
    base commit that exactly those 97 fail identically without this change (plus
    one load-order flake, launch-shell-test.sh, which passes standalone on both
    trees). The new regression test passes in-suite and standalone.

Disclosure: prepared by the sambai-dev agent (Hermes) under human supervision of the diff, per the note on the tracking issue comment.

@scottjones scottjones left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Sorry this sat — tested on an M2 Max (apple,j414c) and the mapping is right: on Apple keyboards F1/F2 are the brightness keys, and the case lands after the lua-cache lookup, so it reaches Omarchy's __lua binds rather than only plain ones. With a cold cache the rows render exactly as intended:

ALT + F1     → Brightness down precise
ALT + F2     → Brightness up precise
F1           → Brightness down
F2           → Brightness up
SHIFT + F1   → Keyboard brightness down
SHIFT + F2   → Keyboard brightness up

One thing to fix before this can help anyone: the cache. output_binding_records serves from keybindings-$(keybindings_cache_key).records, and that key is sha256 of "v11" plus the active keymap plus hyprctl binds — the inputs, not the rendering code. I hit it live: running your patched script on this machine returned the old XF86MonBrightnessUp rows straight out of cache. Anyone whose bindings do not change keeps seeing them indefinitely.

Bumping v11 to v12 in keybindings_cache_key is the fix, and that prefix exists for exactly this. Your test can't catch it because it points XDG_CACHE_HOME at a fresh temp dir, which is always cold — worth a second case that pre-seeds a cache file and asserts the new rendering still wins.

Context that arrived after you opened this: #210 merged, adding Fn-free capture bindings on the media keycodes, so the viewer now also shows SUPER + XF86AudioMute, SUPER + XF86AudioLowerVolume and SUPER + XF86AudioRaiseVolume. Those are F10/F11/F12 on an Apple keyboard, so the same treatment applies — with one wrinkle worth deciding rather than stumbling into: mapping them would render SUPER + F12 → Screenshot Display (Apple top row) directly beside the existing SUPER + F12 → Screenshot Display, two rows that look identical and do the same thing. Hiding the media-key twins from the viewer instead may be the better end state. Either way it is a separate change and shouldn't hold this one up.

Happy to push the v12 bump to your branch if you'd rather not — maintainer edits are enabled here.

@malik-na malik-na left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The mapping itself is right for this fork. On Apple keyboards XF86MonBrightnessUp/Down are F2/F1, Scott confirmed it live on apple,j414c, and putting it in the menu script (display only) is the correct surface — renaming the Hyprland binds would change matching.

Blocker: cache key. keybindings_cache_key hashes v11 + keymap + hyprctl binds. That is the inputs, not the rendering code, so a machine whose binds have not changed keeps serving SHIFT + XF86MonBrightnessUp from cache forever. Scott hit this live. The test cannot catch it because it points XDG_CACHE_HOME at a fresh temp dir.

Bump the prefix. After #233 this file is already at v13 (alternative-chord merge + grave mapping), so the rebase bump is v11 → v14, not v12. Add a case that pre-seeds a stale cache file and asserts the new rendering still wins.

The F10/F11/F12 media-key twins from #210 (SUPER + XF86AudioMute etc.) are the same class of leak and should be a follow-up, not this PR. Mapping them would produce two identical-looking SUPER + F12 → Screenshot Display rows; hiding the media-key copies is probably the better end state.

Rebase onto #233 — it rewrites bin/omarchy-menu-keybindings substantially (v13 cache, alternative chords, grave → ~).

@sambai-dev sambai-dev left a comment •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks both for the reviews, and @scottjones for the live verification on apple,j414c; great to see the mapping confirmed on hardware.

On the cache blocker: you're both right that the old version's disk cache would have pinned stale rows forever. Ported onto current main instead (post-#233 fuzzel rewrite), which dissolves it structurally: keymap symbols now resolve through an in-memory map built per run (build_keymap_cache), so there is no records file to go stale. The mapping now lives in parse_keycodes's passthrough branch, right beside where #233 handles code: and mouse keys, and the menu also drops raw XF86 rows to bottom priority.

The test is ported too: mocks hyprctl plus a minimal xkbcli, asserts SHIFT+F1/F2 render with descriptions, ALT+F2 keeps its modifier, no XF86MonBrightness leaks, and SUPER+Q renders untouched. Full shell suite on my machine: 98 pass / 97 skipped (the skips are QML/Node/hardware-dependent suites; none touch this script).

Agreed on the F10/F11/F12 media-key twins from #210 being a separate change with a real design decision (hide vs. dedupe). Happy to take that as a follow-up once this lands.

On Apple Silicon MacBooks XF86MonBrightnessUp/Down are the physical
F2/F1 keys, so the menu leaked rows like SHIFT + XF86MonBrightnessUp
(issue omacom#194). Name the physical key in parse_keycodes, verified live on
apple,j414c by scottjones.

Based on the post-omacom#233 fuzzel rewrite. The cache prefix is bumped v13 to
v14 so existing installs re-render once; the new stale-cache regression
test pre-seeds a v13 records file and asserts current rendering wins.
Test suite: this file passes; 98/97 pass/skip across shell.d locally.
@sambai-dev
sambai-dev force-pushed the fix/menu-fkey-names branch from 378a8f8 to c58c30d Compare August 26, 2026 11:17
@sambai-dev

Copy link
Copy Markdown
Author

@scottjones @malik-na the branch is rebased onto quattro as requested (single clean commit c58c30d, no merge commits):

  • Mapping ported to the new parse_keycodes awk: XF86MonBrightnessUp/Down become F2/F1 in the passthrough branch, so description-carrying rows and plain rows both render as physical keys.
  • Cache prefix bumped v13 → v14 per malik's note, so every existing install re-renders once after upgrade.
  • New stale-cache regression case: the test pre-seeds a v13 records file with the old XF86 rows, then asserts current rendering wins despite identical mocked inputs. It fails against the pre-fix behavior by construction.
  • Test suite: this file passes; full shell.d run locally is 98 pass / 97 skip (skips are QML/Node/hardware suites that can't run off-Omarchy).

PR shows MERGEABLE now. The F10/F11/F12 media-key twins from #210 remain a deliberate follow-up with the hide-vs-dedupe decision you flagged.

@sambai-dev
sambai-dev requested a review from malik-na August 26, 2026 11:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants