Bind descriptions are load-bearing: give binds a stable id
Splitting this out of #12345 §7, where it is listed as needing its own project, at @WokoFlipper's request in https://github.com/omacom/omarchy/issues/12345#issuecomment-5727650774. It lands with no translation runtime, no catalog and no locale: it is a schema change to default/hypr/bindings/*.lua plus the cheatsheet reader. It is worth doing on its own merits, because today a description cannot be reworded either.
What a description is today
o.bind(keys, description, dispatcher, options) (default/hypr/helpers.lua:92) hands the description to five different roles.
- Display text in the cheatsheet,
bin/omarchy-menu-keybindings. - Join key, on both sides of the awk join that merges alternative chords for one action.
- Input to the ordering rules: 52 literal regexes match on description text to set precedence.
- Round-trip key after selection: the caller recovers which row was chosen from the text it displayed. #12363 is the general fix for that shape.
- A window matcher, for 4 binds.
command_from(default/hypr/helpers.lua:56-72) passes the description as the first argument toomarchy-launch-or-focus-webappwhen a bind is{ webapp = …, focus = true }. That reachesomarchy-launch-or-focus:13, where it is interpolated into a jq regex tested against the window's ownclassandtitle. Those are set by the application, and no locale changes them, so a translated description cannot match: the bind stops focusing the existing window and launches a new one on every press. The four areWhatsApp,Google Messages,Google PhotosandGoogle Maps, atdefault/hypr/bindings/applications.lua:28-31. All four are product names a translator would probably leave alone, which is what makes it a trap rather than a bug.
The scale, at 9c5482c5: default/hypr/bindings/*.lua has 193 o.bind/o.bind_toggle call sites across 6 files, of which 186 pass a literal description, 173 of those distinct; 2 pass none; and 5 build key and description in a loop, which is what makes the rendered list roughly 230 rows. The consequences of editing them are measured in #12345 §7: translating the 186 silently destroys 4 of 4 alternative-chord merges and reorders most of the rendered rows, with no error, no non-zero exit and no failing test. test/shell.d/keybindings-menu-test.sh pins 4 descriptions and, incidentally, 1 of the 52 precedence literals.
The shape that fixes it
A third field: a stable id the machinery keys on, and a description that is only ever displayed.
The migration can be incremental, because the id can default to today's value:
-- default/hypr/helpers.lua
function o.bind(keys, description, dispatcher, options)
local opts = options or {}
opts.id = opts.id or description -- every existing bind keeps working
...
Joins, precedence and round-trips key on id; the cheatsheet renders description. A bind that gains an explicit id becomes editable, and a bind that does not behaves exactly as it does today. The same holds for the user's own ~/.config/hypr/bindings.lua, which enters the same stream.
The one thing that decides the design, and which I cannot measure from here
The cheatsheet reads hyprctl binds, so whatever carries the id has to survive into that output. Two candidates:
- A bind option. If Hyprland passes unknown
hl.bindoption keys through tohyprctl binds -j, the id rides along and nothing else is needed. - A sidecar map from bind to id, generated next to the lua files and joined by the cheatsheet. It needs no upstream support, but the chord is not a stable key either: it moves with the keymap, and the same action appears under alternative chords, which is the reason the merge exists. So a sidecar has to be keyed on chord plus dispatcher, not chord alone.
The measurement that decides it is one command on a running session: set an extra key in opts, then check whether it appears in hyprctl binds -j | jq '.[0]'. @WokoFlipper, @sbelcl, if either of you gets there before I reach a session, that is the whole blocker.
Already in flight
- #12363 gives
omarchy-menu-selecta--print-index, so a caller stops recovering an id by cutting up the row it displayed. That is role 4 above. - #12362 keys the cheatsheet cache on the active collation. Independent of translation, but the same code path: the row order already depends on
LC_COLLATEtoday, and a translated description would reorder rows for a second reason.
Pilot
@WokoFlipper carries 204 translated binding descriptions as an archive that explicitly must not be applied, and runs the merge machinery daily, so that is the largest ready-made label set and the first real consumer. Checking the schema against it before it lands costs less than finding out after. @sbelcl's runtime is independent of this and does not need to land first.
Thank you for spinning this out. Confirming from the pack side: our 204-entry Russian bindings archive flips into a real catalog the day the third field lands — keyed on stable ids, labels translated, zero rework on the Russian side. The window-matcher role is new to me and nasty; good catch. Ready to pilot whenever there's a branch.
The blocking measurement is settled: an extra opts key is accepted, and it goes nowhere
Measured on Hyprland 0.56.2 (efb5099): a headless instance with a throwaway config for the write side, read-only hyprctl queries against a live stock session for the read side.
hl.bind accepts unknown option keys without complaint. Both of these load with no error, no warning in the log, and no change in behaviour:
hl.bind("SUPER + C", hl.dsp.exec_cmd("true"), { description = "Calendar", id = "calendar" })
hl.bind("SUPER + E", hl.dsp.exec_cmd("true"), { description = "Probe", nonsense_key_xyz = 42 })
So opts.id = opts.id or description costs nothing on the Hyprland side. It is also invisible there. hyprctl binds serialises a fixed struct and the id is not in it:
locked mouse release repeat longPress non_consuming auto_consuming has_description
modmask submap submap_universal key keycode catch_all description
allow_input_capture dispatcher arg
No passthrough for unknown keys either: grepping the whole JSON for the id string returns 0.
That is the measurement I said was the whole blocker, and the answer is negative. It turns out not to matter, and the reason is the more useful result.
The consumer that needs an id already re-reads the source
bin/omarchy-menu-keybindings does not take its Lua binds from Hyprland, and cannot: on a live session all 225 binds report dispatcher: "__lua". So it keeps a source-derived cache (build_lua_bind_cache, lines 69-82) that re-executes the binding files under a stub hl to recover the real dispatcher, arg and key. That cache sees the entire opts table.
So an id reaches the only consumer that needs one today, with no Hyprland change, no new file and no upstream dependency. The schema question shrinks from "how do we get an id through Hyprland" to "what does that cache key on", which is entirely ours to decide.
Measured on a stock session (omarchy 4.0.4-1, 225 binds):
binds reporting dispatcher: __lua |
225 of 225 |
| carrying a description | 223 |
| distinct descriptions | 213 |
| no description at all | 2, both Lid Switch, matching the source census above |
| neither key nor keycode in Hyprland's output | 59 |
Those 59 are the loop-generated workspace binds. For them the key the cheatsheet displays exists nowhere in Hyprland's output and is recovered entirely from the source cache, keyed on modmask,description:
key="${LUA_BIND_KEY_MAP["$modmask,$description"]}" # line 298
59 of 225 rows, 26% of the cheatsheet, take their key from a description-keyed lookup. Role 2 in the issue was "awk join key". This is that role with a number on it, and it is a harder dependency than I claimed: not a convenience join, the only source of the value.
The collision is already in the tree
Three pairs share a modmask and a description, which is exactly that cache key:
modmask=1 XF86AudioPause / XF86AudioPlay Switch media source
modmask=65 RETURN / B Browser
modmask=72 TAB / mouse_down Next window in group
One of each pair overwrites the other in the map. It does not bite today: the lookup only fires when Hyprland reports neither key nor keycode, and none of those six binds are in the 59. So it is latent rather than broken, but it is in the tree now, and it goes live the moment any of the six moves into a loop or a code: form. LUA_BIND_DISPATCHER_MAP includes the key in its own cache key (modmask,description,key) and is safe today for the same reason it cannot help here.
Two asides worth recording while I was in there:
argis unique per bind (225 distinct values for 225 binds), which makes it look like a free id. It is not one: the values run as an arithmetic progression in declaration order (6, 8, 10, ... 319, 321, 323, with 2 inversions in 225), so they are Lua registry slots. Insert a bind and everything after it renumbers.- The script parses plain-text
hyprctl bindsbecause 0.56.0 emitted invalid JSON (comment at line 275). On 0.56.2hyprctl binds -jis valid for all 225 binds and the fields line up (no description parses as a dispatcher). Nothing to change here, but it means a real id field, if one ever lands upstream, would be readable with-jrather than awk.
Pilot
@WokoFlipper the window-matcher role is the one I would point your 204 entries at first, because it is the only one of the five where a changed description breaks behaviour instead of display: the four webapp + focus binds pass their description to omarchy-launch-or-focus-webapp as the window match string, so translating those four changes which window gets focused. If your archive covers them, that is the schema's first real test and the cheapest one to run.
The branch I will put up: opts.id defaulting to the description in o.bind, build_lua_bind_cache keyed on the id instead of modmask,description, and explicit ids on the four webapp binds so their match string stops tracking their label. No behaviour change on its own without a translation layer on top, so it is reviewable in isolation. I will ping you here when it is pushed.
Audited our 204-entry archive against the window-matcher role — reporting back since this is exactly the pilot's first test.
Found: 3 of the 4 dangerous translations were present (Google Messages, Google Photos, Google Maps under their SUPER+SHIFT combos; WhatsApp was never translated). All three now dropped from the table, original kept as bindings-ru.tsv.bak-keys.
Bonus find: the table was keyed by key-combo while the generator looks up by English description, so zero TSV rows ever applied (only hardcoded loops emitted). Migrated to EN description → RU: 204 rows → 148 mappings, 0 conflicts; the 44 unmapped rows are all code: loop binds the generator already covers. Dry-run: 157 binds would translate.
Guard: generator gained a DANGEROUS_DESCS set (all four) — skipped with a stderr warning even if re-added. apply not run; live config untouched.
So the archive is now window-matcher-safe by construction, not just by absence. Ready for the opts.id branch — ping me when it's up and I'll rebind the matcher rows to ids.
Branch is up: #12557. Thanks for auditing the archive against this before it existed; three of the four having actually been translated is a better argument for the change than anything I wrote in the issue.
What is in it: opts.id defaulting to the description in o.bind, the menu's Lua bind cache keyed on the id instead of modmask,description, and the four web app binds naming their id outright. No behaviour change on its own, measured rather than assumed: the menu's scan over a stock config emits the same 227 rows before and after, byte identical once the new id column is removed, and 0 of those 227 binds have an id that differs from its description. keybindings_cache_key therefore needs no version bump.
Your bonus find is the same bug from the other side. The generator looked up by English description because the description is the only handle the tree offered; that is exactly what the id is for. Once this lands, your matcher rows key on Google Photos the id while the description next to it is free to become Russian, and DANGEROUS_DESCS can go from "never translate these four labels" to "never translate these four ids", which is a rule about our data instead of a hole in it.
One thing to know before you run that 157-bind dry run for real, because it is outside this PR and I do not want it read as fallout from it. Two places in the menu still classify on English display text: prioritize_entries() holds 52 match(line, /.../) patterns that order the whole cheatsheet, and alternative_chord_actions() hardcodes four English descriptions to decide which chords merge into one row. Translate the descriptions and the cheatsheet quietly falls back to default ordering and stops merging alternative chords. Threading the id to both needs a fourth field through parse_binding_records, which I deliberately kept out of this branch to keep it reviewable; I can put it up next if you want to work against it.
Also worth waiting on: the PR asks one open question about the shape of those four binds, { id = "WhatsApp" } as written versus reusing the string form of focus that { launch, focus } binds already accept. If the maintainers prefer the second, what you rebind to changes shape, so it may be worth letting that settle before touching the matcher rows.
On your 44 unmapped code: rows: leaving those to the generator's loops is right. They are the 59 of 225 binds Hyprland reports with neither key nor keycode, and their description is still the only thing it offers to find the key by. That lookup stays description-keyed even after this PR, but both sides of it read the same config, so a translated description matches itself and nothing breaks.
Thanks for the ping — reviewed the branch, and we are in as pilot.
One data point from the Russian side on product names: WhatsApp is never translated here — kids to grandparents know it only in the Latin spelling. So stable ids with free labels is exactly the right shape for us: our pack keeps product names as-is by language fact, not by exception list.
On process, agreed on both counts:
- waiting with the matcher rows until the
{ id }vsfocus =question settles; - yes to the follow-up with the fourth field through
parse_binding_records— ordering and chord merges are precisely what our 254 translated descriptions will exercise, so point us at that branch when it exists and we will run it live.
DANGEROUS_DESCS flips from "never these four labels" to "never these four ids" the day the shape lands — no rework on our side.
Pilot results from our box (bind-stable-id branch, fresh fetch):
hyprland-bind-id-test.sh: 9/9 pass, unmodified, on our machine.- 227-row check reproduced: extracted the scan from the branch script and from its parent, ran both over the same stock tree — 230 rows each side on this tree (newer than your 4.0.4-1, hence 230 vs 227), byte identical once the id column is removed, 0 ids differing from their description.
qconsole.lua:123gap reproduced on a live user config:attempt to compare number with table, exact same error — user binds never reach the scan, as you found.
So the neutrality claim holds outside your session too. Waiting on the { id } vs focus = decision before touching our matcher rows.
Worth adding because it arrived from the maintainers rather than from this thread. #13521 landed this week and hit the same wall from the other side. It makes SUPER + RETURN a Lua function, o.bind("SUPER + RETURN", "Terminal", o.launch_terminal()), so the launcher can be handed the focused window's pid; and a function bind is one the menu cannot run, because hyprctl binds reports it as __lua and nothing else. The fix it shipped, in default/hypr/helpers.lua:
-- The command each function bind stands for, so the keybindings menu can still
-- run a bind that Hyprland only reports as Lua.
o.bind_commands = {}
o.bind_commands[launch] = "omarchy-launch-terminal"
read back by the menu's own scan as elseif o and o.bind_commands and o.bind_commands[bind_dispatcher] then.
That is a side table whose purpose is to let the menu recognize a bind Hyprland under-reports, keyed on a stable handle, and the handle it picked is the Lua function object. The description was one field away in the same opts table and was not used. So the shape this issue asks for is the shape the tree already reaches for when the problem comes up; what is missing is a handle a config file can write down, since a function object exists only at runtime and only for the binds that happen to be functions.
Two smaller notes from rebasing #12557 onto it. The same commit added five command_from branches (menu, panel, audio, brightness, ipc) and none of them touch the description, so the coupling count in §7 has not grown: still five, and the window matcher is still the load-bearing one. It also bumped keybindings_cache_key from v13 to v14, which is the bump #12557 measures its way out of needing.
Agreed this should land as its own schema change — descriptions today are display text, matcher keys, and cheatsheet copy all at once.
Tracking implementation on #12557 (currently CONFLICTING) plus follow-ons #13888 / #13923. Once #12557 rebases green, this issue can close against it.