Repository navigation
fix(linux): load Hyprland Lua binds from a file Hyprland reads - #96
Open
kalopsia-space wants to merge 1 commit into
Open
kalopsia-space wants to merge 1 commit into
kalopsia-space wants to merge 1 commit into
Conversation
With a hyprland.lua config, FTHR wrote its hl.bind() block into custom/keybinds.lua. Only the illogical-impulse (end-4) dotfiles load that file; plain migrated configs, CachyOS and Noctalia do not, so the binds were never registered and nothing said so, because the dead-hotkey warning returned early on Hyprland (#91). - Keep custom/keybinds.lua only when hyprland.lua requires it. Otherwise write ~/.config/hypr/fthr-hotkeys.lua and append one marked line, pcall(require, "fthr-hotkeys"), to hyprland.lua, mirroring the hyprland.conf source line: skipped when already present or when the user binds the socket by hand, never on an unreadable config, never creating one. A stale FTHR block left in an unloaded custom/keybinds.lua is removed so a later require cannot double-bind. - After hyprctl reload, and on startup when nothing changed, read `hyprctl binds -j` on the existing background thread. Conf binds are found by the socket path in arg; Lua binds by their "FTHR Clips:" description, since exec_cmd binds are listed as __lua closures. When none is loaded, warn once with the file written and the exact line to add. A missing or failing hyprctl skips the check. - Probe nc -h for -U. GNU netcat and BusyBox nc lack it, so binds fired and delivered nothing. socket_command() falls back to `socat - UNIX-CONNECT:<sock>` when socat exists; otherwise the user is told to install openbsd-netcat or socat. Hyprland now reports this instead of returning early.
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 Hyprland 0.55+ with a
hyprland.luaconfig (CachyOS, Noctalia shell, EndeavourOS reports in #91), no FTHR hotkey does anything, and FTHR shows no warning.Root cause
_apply_compositor_config()wrote thehl.bind(...)block into~/.config/hypr/custom/keybinds.luawhenever that file orhyprland.luaexisted. Only the illogical-impulse (end-4) dotfiles load that file fromhyprland.lua. In any other config the binds sit in a file Hyprland never reads._warn_if_linux_hotkeys_dead()returned early on Hyprland ("binds are auto-written; hotkeys work via the socket"), so the failure was silent.echo -n action | nc -U <sock>. GNU netcat and BusyBox nc have no-U, so with either of them a bind fires but delivers nothing. This was silent too.What Hyprland does (sources)
hyprland.luais the config and hyprlang is deprecated. Binds are writtenhl.bind(keys, hl.dsp.exec_cmd(cmd), { description = ... }), and other files are loaded withrequire(), using paths relative tohyprland.luawith.or/as the separator. Requiring a missing module aborts the calling file;pcall(require, ...)is the documented guard. Sources: https://wiki.hypr.land/0.56.0/Configuring/Start/ ("Using Multiple Configuration Files", "Require") and https://wiki.hypr.land/0.56.0/Configuring/Basics/Binds/src/config/lua/ConfigManager.cppprepends<config dir>/?.lua;<config dir>/?/init.luatopackage.pathat v0.55.0, v0.56.0 and v0.57.0. A bare module name next tohyprland.luatherefore resolves on every Lua-config release. Absolute-pathrequire(isExplicitRequirePath) first appears in v0.56.0. In v0.55.0,safeLuaRequireonly reports errors and does not rethrow them.src/config/lua/bindings/LuaBindingsToplevel.cpp(v0.56.0) stores Lua binds ashandler = "__lua"witharg = <registry ref>.hyprctl binds -j(src/debug/HyprCtl.cpp) printsdispatcher,arganddescription. For a Lua bind the command is not visible, but the description is.Change
Write to a file that is loaded. If
hyprland.luarequirescustom.keybindsorcustom/keybindsoutside a comment and that file exists, the old behaviour stays. Otherwise FTHR writes~/.config/hypr/fthr-hotkeys.luaand appends one marked line tohyprland.lua:This works the same way as the
hyprland.confsource =line:hyprland.luaalready contains the line or the user's ownhotkey.sockbinds.A complete stale FTHR block left in an unloaded
custom/keybinds.luaby earlier builds is removed. An incomplete block is left alone.Check after reload. After
hyprctl reload, and on startup even when nothing changed, FTHR readshyprctl binds -jon the existing background thread. It retries 3 times, 0.5 s apart. Conf binds count as loaded whenargcontains the socket path, Lua binds when the description starts withFTHR Clips:. If neither matches,error_occurredshows HYPRLAND HOTKEYS NOT LOADED once, naming the file written, the main config and the exact line to add. A missing hyprctl, a non-zero exit or unparsable output skips the check.nc check.
linux_tools.nc_supports_unix()looks for-Uin thenc -houtput, which matches OpenBSD nc and ncat.linux_tools.unix_socket_client()returns nc when it has-U, otherwise socat if installed.socket_command()is still the only place the bind command is built, and it emitssocat - UNIX-CONNECT:<sock>when socat is the client. With neither tool usable, the user is told to install openbsd-netcat or socat.On Hyprland,
_warn_if_linux_hotkeys_dead()now reports a socket client that cannot work, instead of returning early.Testing
tests/test_hyprland_binds.py:hyprland.lua, end-4 dot form and slash form, a commented-out require, stale-block cleanup, an incomplete block, idempotency, manual binds, an unreadable config, a failed write, conf/Lua selectionhyprctlandsubprocess: Lua match by description, conf match by arg, the warning text and that it is shown once, the startup check with no reload, hyprctl failures, a missing hyprctl, no keys bound, no sessiontests/test_linux_tools.py: OpenBSD nc, ncat, GNU nc and unprobeable help text; socat fallback; the missing-nc message; socat in the generated command._FTHR_HYPR_LUA), and there is no real hyprctl.HYPRLAND_INSTANCE_SIGNATURE/WAYLAND_DISPLAY/DISPLAYunset.ruff check .is clean.Refs #91