Skip to content

Dispatch Lua function keybindings from the menu - #11851

Open
vdvoorder wants to merge 1 commit into
omacom:quattrofrom
vdvoorder:keybindings-menu-lua-function-binds
Open

vdvoorder wants to merge 1 commit into
omacom:quattrofrom
vdvoorder:keybindings-menu-lua-function-binds

Conversation

@vdvoorder

Copy link
Copy Markdown

Super + K lists Lua function bindings, but selecting one did nothing. For example, a user who zooms in, searches for Reset zoom, and presses Enter gets no reset or message; the script exits 1. Five of the 232 default bindings on Omarchy 4.0.2 are affected: Zoom in, Reset zoom, and the three universal clipboard actions. User-defined function binds have the same failure.

The menu replays the Lua config to recover each action, but a plain Lua function leaves no expression to replay. Hyprland reports these binds as __lua with a registry ref. When an expression is available from the source, the expression still wins. Otherwise, the menu records the bind's modifier mask, submap, key, keycode, and description.

A config reload can assign the same registry ref to a different function. At dispatch time, the menu rereads hyprctl binds and requires exactly one __lua bind to match the recorded identity. The menu calls the ref currently attached to that bind through the existing hl.dispatch path, and refuses a blank or nonnumeric ref. The cache version moves from v13 to v14 so cached rows with blank dispatcher fields are rebuilt.

PR #11733 is a broader rewrite of the keybindings scan across 11 files. This PR keeps that work separate and fixes the current script.

Testing

  • bash test/shell.d/keybindings-menu-test.sh: all 22 assertions passed (15 existing and 7 new).
  • bash test/shell.d/bin-style-test.sh: passed.
  • git diff --check: passed.
  • Live on Omarchy 4.0.2-1 with Hyprland 0.56.2: selecting Reset zoom through the patched script changed zoom_factor from 2 to 1.
  • ./test/cli: passed.
  • ./test/shell: 235 of 238 test files passed. The three failures (config-test.sh, snapper-test.sh, and unowned-system-paths-test.sh) each stop at their first check because they require an omarchy-pkgs checkout that is not present on this machine. All three fail the same way on the unchanged base commit b679363b.

Not included

The comma-delimited binding record format remains unchanged. A description or key containing a comma already breaks the row for every bind kind, and none of the shipped defaults has one. Reworking the record framing would also require changes to parse_binding_records, static_bindings, and every test that reads rendered rows, so that belongs in a separate change.

The keybindings menu could list Lua function binds but could not run
them. Replaying the Lua config produces no dispatcher expression for a
plain function, so selecting Reset zoom from Super + K exited 1 without
changing the zoom level. The same bug affects five default bindings and
user binds that use functions.

When no source expression exists, record the bind identity reported by
Hyprland. At dispatch time, reread `hyprctl binds` and require exactly
one bind with that identity. Call its current registry ref only when the
ref is numeric; refuse blank refs, duplicate matches, missing matches,
and failed bind queries.

Bump the cache version from v13 to v14 so records with blank dispatchers
are rebuilt. Keep the comma-delimited record framing unchanged because
commas in keys or descriptions already break every bind kind and need a
separate change.
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.

1 participant