feat(converter): align dispatcher + env mappings with Hyprland 0.55 typed Lua API - #7
Merged
Merged
Conversation
…yped Lua API
Rewrites every legacy hyprlang dispatcher mapping against the official
0.55 wiki and Hyprland source (LuaBindingsDispatchers.cpp,
LuaBindingsConfigRules.cpp, KeybindManager.cpp). Earlier passes emitted
positional args where the typed API requires tables, mis-mapped a few
semantics, and used polyfill helpers for features the typed API now
covers natively.
Highlights:
- env / envd: route to hl.env(K, V) and hl.env(K, V, true) — the third
arg is the dbus boolean per Hyprland source. envd's systemd / D-Bus
propagation no longer needs a polyfill helper.
- execr-once -> hl.dispatch(hl.dsp.exec_raw(cmd)) (native; previous
setsid-wrapping polyfill was inverse of exec_raw's "no shell" semantic).
- focusworkspaceoncurrentmonitor -> hl.dsp.focus({on_current_monitor=true})
(native field; polyfill dropped).
- loadconfig -> inline `function() hl.exec_cmd("hyprctl reload") end`.
- movecurrentworkspacetomonitor -> inline closure resolving the active
workspace via hl.get_active_workspace().
- 15+ dispatchers moved from positional to typed-table emission:
signal, signalwindow, setprop, tagwindow, alterzorder, fullscreenstate,
fakefullscreen, lockactivegroup, lockgroups, denywindowfromgroup,
changegroupactive (f/b -> next/prev, numeric -> active{index}),
moveintogroup / moveoutofgroup (window namespace, window selector),
cyclenext, swapnext (swap, not cycle_next), swapwindow, renameworkspace,
moveworkspacetomonitor, swapactiveworkspaces, dpms, pass, sendshortcut,
sendkeystate, movecursor, movecursortocorner, centerwindow.
- New dispatcher mappings: forcekillactive, signalwindow, toggleswallow,
movewindoworgroup, movegroupwindow, noop, movewindow mon:NAME [silent].
- killwindow now maps to kill (SIGKILL) per 0.54 wiki, not close.
- focuscurrentorlast -> focus({last=true}); no current_or_last field
exists in 0.55.
- Always emit action="toggle" on fullscreen_state because 0.55's default
is "set" (verified in Hyprland source) where 0.54's was "toggle".
- set_prop always quotes value as Lua string; the typed API requires a
string and would reject numeric literals at config load.
Beyond dispatchers:
- CSS-shorthand gap values (`gaps_in = 5 10 15 20`) parse into the typed
HL.CssGap struct { top, right, bottom, left } per CSS box-shorthand.
Applies to general.gaps_in/gaps_out/float_gaps and monitorv2 reserved.
- Source globs (`source = path/*.conf`) emit hl_source_glob — the one
remaining polyfill, since require()/dofile can't glob.
- submap = NAME ... submap = reset buffers contained bind* directives
and emits hl.define_submap("NAME", function() ... end).
- exec/hyprctl-dispatch rewrites: bind = ..., exec, hyprctl dispatch X
is detected and routed through the direct hl.dsp.* call.
Undeclared $var handling:
- Two-mode formatter: g.fmtVal (default, fast-fails on undeclared $X by
emitting a Lua local reference) vs g.fmtShell (preserves $HOME / $XDG_*
verbatim so /bin/sh expands at runtime). Shell-context callers (exec,
execr, formatExecCall) use fmtShell; everything else (bind keys, config
values, dispatcher table fields) uses fmtVal so typos surface as load
errors instead of silently non-matching binds.
Tests + goldens:
- New polyfills_test.go covers each migrated path with on/off polyfill
variants where relevant.
- New testdata/05_polyfills.conf fixture exercises every helper + the
env-var fallback + CSS-shorthand gap path end-to-end (golden + merged
golden refreshed).
- Golden test's merged case now runs with MergeCalls=true AND
Polyfill=true to mirror CLI / web-UI production defaults.
- Existing TestModifierCaseNormalization updated to declare \$mainMod
explicitly (the prior test relied on the now-fixed eager $-rewrite).
- All commit-level dispatcher reshapes verified through luac -p on the
comprehensive 137-line end-to-end output and a real-world user config
(304 hyprlang lines -> 336 Lua lines, 100% coverage, 0 flagged).
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.
Summary
killwindow→killnotclose,swapnext→swapnotcycle_next,focuscurrentorlast→focus({last=true}),fullscreen_statedefault action explicitlytogglesince 0.55 defaults toset).envd→hl.env(K, V, true),execr-once→hl.dispatch(hl.dsp.exec_raw(...)),focusworkspaceoncurrentmonitor→focus({on_current_monitor=true}),loadconfig→ inlinehyprctl reloadclosure). Onlyhl_source_globremains sincerequire()/dofile()can't glob.\$HOME/\$XDG_*survives inside exec strings for/bin/shto expand; declared\$mainModstill rewrites to a Lua local; non-shell contexts fast-fail on undeclared refs), CSS-shorthand gap parsing into the typedHL.CssGapstruct, and submap-block buffering intohl.define_submap("name", function() ... end).Test plan
go test ./...passes (incl. newpolyfills_test.gocovering each migrated dispatcher with on/off polyfill variants)go vet ./...cleango test ./internal/converter -fuzz FuzzConvert -fuzztime 15sno panics(cd web/wasm && GOOS=js GOARCH=wasm go build -o /tmp/main.wasm .)succeedsgo run ./cmd/hyprlang2lua ~/.config/hypr/hyprland.conf | luac -p /dev/stdinproduces syntactically valid Lua.luain a Hyprland 0.55 session and confirm bindings behave (only static syntax validated locally; runtime smoke test is the user's call)