Repository navigation
Render every modifier Hyprland can bind in the keybindings menu - #12042
jimjimovich wants to merge 6 commits into
Conversation
modmask_to_text enumerated only SHIFT/CTRL/ALT/SUPER combinations, so a bind on Mod2, Mod3 or Mod5 fell through to the numeric fallback and showed up as a raw mask: remapping Caps Lock with `caps:hyper` binds on Mod3 and rendered as "32 + K" instead of a modifier name. Derive the text from the bits instead of enumerating combinations. The sixteen masks the table already covered render byte-identical. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Automated AI review
Verified: the premise and the main change hold. Three gaps remain: one modifier bit is still unnamed and is now dropped silently, existing menu caches keep the old text, and the new rows still cannot be launched from the menu. Bit value 2 (
|
| Mask | Base | Head |
|---|---|---|
| 2 | 2 |
(empty) |
| 3 | 3 |
SHIFT |
| 66 | 66 |
SUPER |
End to end with a stubbed hyprctl binds, a SUPER + CAPS + J bind printed as a second SUPER + J row next to a real SUPER + J bind, and CAPS + H and H for the same action became indistinguishable: two identical H rows, merged into one when their records also match (dedupe_binding_records compares the rendered record).
Impact: a CAPS chord reads as a different, unmodified or already-taken chord. default/agents/skills/omarchy/hyprland.md tells the agent to use omarchy menu keybindings --print to check whether a key is already bound, so the wrong text can also mislead that check. CAPS binds are uncommon (with Omarchy's default compose:caps, holding Caps Lock gives modmask 0), but the PR's "every modifier" claim and the test title do not hold without it, and the code comment leaves CAPS out.
Suggested change: add '2:CAPS' to the list:
for modifier in '64:SUPER' '1:SHIFT' '2:CAPS' '4:CTRL' '8:ALT' '16:MOD2' '32:MOD3' '128:MOD5'; doNone of the 16 previously covered masks contains bit 2, so their output is unchanged, and the PR's test still passes with this line. An assertion such as modmask_to_text 66 == "SUPER CAPS" would cover it.
The records cache version is not bumped
output_binding_records serves keybindings-<key>.records from the cache directory whenever that file exists and is non-empty. keybindings_cache_key hashes only the literal v13, the active keymap line and the raw hyprctl binds output, and none of these change when modmask_to_text changes.
Reproduced with a shared cache directory and the same stubbed binds:
base, empty cache -> writes keybindings-9f727f8f….records, prints "32 + K"
head, same cache -> reuses the same file, prints "32 + K"
head, v13 -> v14 only -> writes a new file, prints "MOD3 + K"
Impact: users who already opened the menu with a Mod2/Mod3/Mod5 bind, the users this PR is for, keep seeing the raw number until their binds or keymap change or they clear the cache.
Suggested change: printf 'v14\n' in keybindings_cache_key. Eight of the nine commits to this file since the cache was added bumped this literal; the ninth removed a priority rule together with its bind. Several open PRs also bump it to v14, and identical bumps merge without a conflict, so whichever lands second should move past the value already on quattro.
Adjacent: the Lua scan cannot match the new modifiers, so the rows do not launch
Every o.bind goes through hl.bind, which Hyprland reports with dispatcher __lua. The menu recovers the real command from a source scan keyed on modmask, description and key. That scan's table (bin/omarchy-menu-keybindings line 85) knows only SHIFT, CTRL, CONTROL, ALT and SUPER, so for MOD3 + K it computes modmask 0 while Hyprland reports 32. The lookup misses, the dispatcher stays empty, and dispatch_binding returns 1 without doing anything.
In an isolated run with a minimal config binding MOD3 + K, CAPS + J and a SUPER + ALT + F12 control bind, the control row resolved on both base and head, while the MOD3 and CAPS rows had empty dispatch fields on both. With the table extended to the names Hyprland accepts, all of them resolved.
Impact: not a regression, since the base has the same gap, but the PR's own MOD3 + K example now renders by name and still does nothing when selected from the menu.
Suggested change: extend the table to match Hyprland's modFromSv (src/config/lua/bindings/LuaBindingsToplevel.cpp), here or in a follow-up:
local modifiers = {
SHIFT = 1, CAPS = 2, CTRL = 4, CONTROL = 4, ALT = 8, MOD1 = 8,
MOD2 = 16, MOD3 = 32, SUPER = 64, WIN = 64, LOGO = 64, MOD4 = 64,
META = 64, MOD5 = 128,
}With the stock config under the menu's stub, the scan currently stops at default/hypr/qconsole.lua before it reaches the user's bindings.lua, so no user Lua bind resolves there at all (same on base, head and tip). Open PR #13276 gets the scan past that point (#12712 and #12916 address other scan-stub issues). With #13276 applied, a SUPER user bind resolves but MOD3 + K still does not, since it does not change this modifier table.
Related PR: #11733 removes modmask_to_text and the Lua scan entirely, reading modifiers from their original spelling. It overlaps with this PR in both files.
Review information
Test scope: pinned head 1e6132a2, merge base 2fbac0c8 and quattro at 616feda1 (neither changed file differs between base and tip). test/shell.d/keybindings-menu-test.sh, an old/new comparison over all 256 masks and end-to-end --print runs with a stubbed hyprctl binds (output format read from Hyprland v0.56.2 source) ran in an isolated sandbox. The Mod3 premise was checked with xkeyboard-config and libxkbcommon in the sandbox. No live Hyprland session was used, and the full ./test/shell suite was not run, so the three unrelated failures the PR description mentions were not assessed. The suggested changes were tried only as local mutants to confirm they work.
AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.
Opt out: To stop receiving these reviews, reply to this comment saying so.
Both sides appended a case to the end of keybindings-menu-test.sh; both are kept.
…ndered The cache stores rendered rows and is keyed on hyprctl binds, which this change does not alter, so a menu already cached as "32 + K" would keep showing it after the update. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hyprland binds CAPS on bit 2. Deriving names from the bits without it turned a SUPER + CAPS + K bind into SUPER + K, where the old table at least showed 66. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-Authored-By: Codex Medium <noreply@openai.com>
|
Reviewed and reproduced. The bug is real and this fixes it. I pushed three commits to your branch, and the head is now Reproduction, on a worker built from the Omarchy ISO, with a stubbed Pushed:
Tests, on the worker at Second opinion: Codex at medium effort reviewed two rounds. In the first it found the dropped Related, not part of this pull request: picking a bind from your This is waiting on the maintainer. It is verified, but it can't be marked ready while the suite is red on |
[Medium impact] The PR appears safe to merge, though full-menu coverage for the newly named modifiers is still missing. Findings
SummaryThe PR replaces enumerated modifier combinations with bitwise formatting so the keybindings menu can name all eight Hyprland modifiers. It also invalidates cached records and adds focused formatter tests. The earlier request for a full-menu test remains unaddressed. Reviews (2) · Last reviewed commit: "Merge quattro into render-all-modifier-b..." · Reviewed by Greptile |
| eval "$(sed -n '/^modmask_to_text()/,/^}/p' "$ROOT/bin/omarchy-menu-keybindings")" | ||
|
|
||
| [[ $(modmask_to_text 32) == "MOD3" ]] || | ||
| fail "a Mod3 bind renders its modifier by name" "$(modmask_to_text 32)" | ||
| [[ $(modmask_to_text 16) == "MOD2" ]] || | ||
| fail "a Mod2 bind renders its modifier by name" "$(modmask_to_text 16)" | ||
| [[ $(modmask_to_text 128) == "MOD5" ]] || | ||
| fail "a Mod5 bind renders its modifier by name" "$(modmask_to_text 128)" | ||
| [[ $(modmask_to_text 33) == "SHIFT MOD3" ]] || | ||
| fail "a Mod3 bind combines with other modifiers" "$(modmask_to_text 33)" | ||
| [[ $(modmask_to_text 66) == "SUPER CAPS" ]] || | ||
| fail "a Caps bind keeps its modifier rather than rendering as the bare key" "$(modmask_to_text 66)" |
There was a problem hiding this comment.
New masks lack menu coverage The new assertions check
modmask_to_text by itself, but none pass a Mod2, Mod3, Mod5, or Caps bind through the stubbed hyprctl and keybindings --print path already used in this test. A full-menu case for MOD3 + K would catch parsing or record-formatting regressions that these assertions miss.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
quattro bumped the keybindings cache key to v16 and appended a translation test to the end of keybindings-menu-test.sh; this branch had bumped it to v15 and appended its modifier tests there. Both tests are kept, and the key moves to v17, since a menu cached at v16 by quattro still holds rows rendered with raw modifier masks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This stopped merging cleanly after The conflict: Reproduction, on a worker built from the Omarchy ISO, with a stubbed Tests, on the worker: Second opinion: Codex at medium effort reviewed the merge and the change against the new This is waiting on the maintainer. |
quattro bumped the keybindings cache key to v17 and added the leading keyboard layout to it, in the same lines where this branch had moved the key to v17. Both changes are kept and the key moves to v18, since a menu cached at v17 by quattro still holds rows rendered with raw modifier masks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This stopped merging cleanly when The conflict: Reproduction, on a worker built from the Omarchy ISO, with a stubbed Tests, on the worker: Second opinion: Codex at medium effort reviewed the merge resolution and the change against the new It's verified at this head. It is waiting for CI to run on the new head, then on the maintainer. |
|
The cause of the failed translation CI on I checked the workflow's test commands on a disposable worker built from the Omarchy ISO. GPT-6 in Codex (effort not exposed), Opus 5.5 High, and muse-wonder via pi at high thinking reviewed this CI diagnosis. Both reviewers found no branch change justified by this evidence; their agreement is not guaranteed to be independent. No commits were pushed. This waits on the maintainer to investigate the GitHub workflow failure; the branch also conflicts with current |
omarchy-menu-keybindingsrenders a raw number instead of a modifier name for any bind that uses Mod2, Mod3 or Mod5.modmask_to_textenumerated the sixteen SHIFT/CTRL/ALT/SUPER combinations and fell through to a numeric fallback for everything else. Hyprland can bind eight modifier bits, so the other three had no case and printed their mask.Remapping Caps Lock to Hyper is the common way to hit this —
caps:hyperbinds on Mod3, soMOD3 + Kshows up in the menu as:Reproduce
Then
omarchy menu keybindings --print.Fix
Derive the text from the bits rather than enumerating combinations, which covers all eight modifiers and shortens the function.
Testing
test/shell.d/keybindings-menu-test.shpasses, with two cases added: one that every modifier Hyprland can bind renders by name, and one that the masks the table already covered are unchanged.All sixteen masks the old table covered render byte-identical, so nothing changes for a configuration that does not use Mod2/Mod3/Mod5.
The rest of
./test/shellwas run as well. Three failures in my environment are unrelated to this change —bar icons share slot and baseline geometryreproduces on an unmodifiedquattrocheckout, and the other two are the graphical bar suite and a check that wants a siblingomarchy-pkgscheckout I do not have.