fix(linux): register toggle hotkey via hyprctl eval on Hyprland Lua configs - #31
Open
jondkinney wants to merge 1 commit into
Open
fix(linux): register toggle hotkey via hyprctl eval on Hyprland Lua configs#31jondkinney wants to merge 1 commit into
jondkinney wants to merge 1 commit into
Conversation
…onfigs Newer Hyprland (0.55+) supports a Lua config manager (`~/.config/hypr/ hyprland.lua`, as omarchy now ships). Under that "non-legacy" parser `hyprctl keyword "bind = ..."` is rejected with "keyword can't work with non-legacy parsers. Use eval." — so the daemon's runtime toggle bind never lands and the shortcut silently does nothing (the daemon, IPC, and `vernier toggle` all stay healthy, which masks the failure). `register_hyprland_toggle_for` / `unregister_hyprland_toggle` now try the legacy `keyword` path first and fall back to `hyprctl eval` with the `hl.bind` / `hl.unbind` Lua API when the config is Lua. Adds `accel_to_hyprland_lua` (the `MOD + MOD + KEY` form) plus small `hyprctl_cmd` / `hyprctl_output_needs_lua_eval` / `lua_escape` helpers. Note: `hyprctl keyword` *exits 0* even when it prints the non-legacy rejection, so the "needs eval" check is ordered before the `status.success()` arm — otherwise the fallback never fires and registration silently no-ops while logging success. Legacy hyprlang configs are unaffected. Verified end-to-end on Hyprland 0.55.3 + a Lua config: the bind appears in `hyprctl binds` (modmask 77, key F) and toggles measurement. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On newer Hyprland (0.55+) with a Lua config manager (
~/.config/hypr/hyprland.lua, as omarchy now ships), the toggle hotkey silently stops working. The daemon registers its runtime bind viahyprctl keyword "bind = …", which the non-legacy Lua parser rejects:So no keybind is ever registered —
hyprctl bindsshows zero vernier entries and pressing the shortcut does nothing. Everything else stays healthy (daemon, IPC,vernier togglefrom CLI/menu all work), which masks the failure and makes it look like a binding problem rather than a parser-compat one.Fix
register_hyprland_toggle_for/unregister_hyprland_toggletry the legacykeywordpath first and fall back tohyprctl eval+ thehl.bind/hl.unbindLua API when the config is Lua. Legacy hyprlang configs are unaffected.accel_to_hyprland_luaproduces theMOD + MOD + KEYform Lua expects (e.g.SUPER + CTRL + ALT + SHIFT + F).hyprctl_cmd,hyprctl_output_needs_lua_eval,lua_escape.Subtle bug worth a look in review
hyprctl keyword "bind=…"exits0even when it prints the non-legacy rejection. So the "needs eval" branch is intentionally ordered before thestatus.success()arm — otherwise the success arm wins, the fallback never fires, and registration silently no-ops while logging success.Verification
End-to-end on Hyprland 0.55.3 + a Lua config:
hyprctl eval hl.bind: …).hyprctl binds(modmask: 77,key: F,description: Vernier toggle).__luawith no command text — grephyprctl bindsby description, not"vernier".🤖 Generated with Claude Code