Skip to content

Feat: Implement some lua support - #389

Draft
H3rmt wants to merge 8 commits into
hyprland-community:masterfrom
H3rmt:lua
Draft

H3rmt wants to merge 8 commits into
hyprland-community:masterfrom
H3rmt:lua

Conversation

@H3rmt

@H3rmt H3rmt commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

I will implement some lua support, mostly for parts that I need myself.

  • Binds
  • Window / layerrules

@H3rmt

H3rmt commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

At the moment I wont add more lua support as all features I intend to use are implemented

@Mirilindo

Copy link
Copy Markdown

Hi @H3rmt — I've been trying to get the Lua write path working again for downstream crates, and I
ran your branch locally rather than just reading it. It's a solid base, and the generated Lua is
correct where it's implemented; thanks for doing the unglamorous part.

Since you said you're done adding features here, I'd rather offer fixes than open a competing PR.
Here is what I measured on your branch merged into current master (Hyprland 0.56.2,
cargo 1.98.1):

1. The CONFLICTING label is 3 lines of Cargo.toml. Your tracing dependency lands next to
master's chardetng/encoding_rs from #395 — one purely additive hunk, both sides kept. Every
other file auto-merges despite the commits landed on master since your base.

2. format_relative lost the .abs() from the original.

// src/dispatch_new.rs:135
_ => format!("-{int}"),          // int is already negative -> "--3"

// src/dispatch.rs:256 (original)
format!("{extra}-{}", int.abs())

This affects five variants: WorkspaceIdentifier::{Relative, RelativeOnMonitor, RelativeOnMonitorIncludingEmpty, RelativeOpen} and
WorkspaceIdentifierWithSpecial::Relative. Hyprland rejects the result
(warning: =[C]:-1: Bad workspace). It does surface as an Err, so nothing fails silently.

3. test_key_bindinds fails, but the code is right — the expectation has a stray ).

left:  hl.bind("TAB", hl.dsp.focus({ direction = "u", }), { })
right: hl.bind("TAB"), hl.dsp.focus({ direction = "u", }), { })
                    ^

19 passed, 1 failed, before and after the merge.

4. FocusLast / FocusUrgentOrLast emit an array element instead of a named field.

You emit hl.dsp.focus({ last }), which in Lua is { [1] = last } where last is an undefined
global — i.e. an empty table. Hyprland reads both as named booleans:

// src/config/lua/bindings/LuaBindingsDispatchers.cpp:1137-1147
auto urgent = Internal::tableOptBool(L, 1, "urgent_or_last");
auto last   = Internal::tableOptBool(L, 1, "last");

and otherwise falls through to configError. Confirmed on a live 0.56.2 — dispatching a table
that is empty in exactly the same way gives:

$ hyprctl dispatch 'hl.dsp.focus({ nonexistent_global })'
error: =[C]:-1: hl.focus: unrecognized arguments. Expected one of: direction, monitor, window, urgent_or_last, last

So these need { last = true } and { urgent_or_last = true }. Worth flagging that the wiki's own table writes focus({ last }) as
a parameter-name notation, not literal Lua — I nearly read it the same way.

For the record, the rest of the generated Lua checks out against a live 0.56.2:

hl.dsp.exec_cmd("true")                                        -> ok
hl.dsp.focus({ workspace = "5", on_current_monitor = true, })  -> ok
hl.dsp.no_op()                                                 -> ok

How would you like to handle this? I'm happy to (a) open a PR against your branch with these
four fixes, (b) let you take them directly, or (c) pick the branch up and carry it forward if
you'd rather be done with it. Your call — it's your work and I don't want to fork the effort.

There is a larger question that belongs in #391 rather than here: as it stands, this PR is opt-in
behind the lua feature with dispatch left untouched, so existing users stay broken even after
a merge. That's a maintainer decision rather than yours, but it changes what "finished" means for
this branch.

@H3rmt

H3rmt commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

Hyprland is quite fast moving, so I think it should be ok to completely drop the "old" config support and just offer lua.

You can just open a pr against my fork, just like H3rmt#1.

The main reason I did not continue further was because everything I needed worked, although it seems like I messed up some of the dispatchers.

We could try to make the witch to lua backwards compatible, but personaly I dont relay care for that. This would also allow us to do a bit of restructuring. (like structuring the dispatchers to match the hl.dsp.workspace, hl.dsp.window, etc.)

@Mirilindo

Copy link
Copy Markdown

Opened H3rmt#2 with the fixes.

Agreed on dropping the old config support — hyprwm/Hyprland#15539 removed the legacy config
manager from main in July, so hyprland.conf stops loading at the next release regardless.

The same PR also removes keyword from the IPC (-registerCommand(SHyprCtlCommand{"keyword", false, dispatchKeyword});). That kills Keyword::set outright, since it sends keyword <k> <v>
verbatim:

// src/keyword.rs:453
instance.write_to_socket(command!(Empty, "keyword {} {}", key, value))?;

eval with hl.config is the only route left for it. Keyword::get is fine, getoption
survives. Three of the published crates depending on hyprland call Keyword::set today, and
nothing in #389 touches that path — worth knowing while the shape of this is still open.

Lua-only also puts a floor under the crate: src/config/lua does not exist before 0.55, so the
next release is a breaking one and should say which Hyprland it needs. That is the cheap moment
for the hl.dsp.window / hl.dsp.workspace restructuring you mentioned, since it is easier
before the remaining dispatchers are written than after. Happy to write them in whatever shape
you settle on.

Also: #1 from @mitsaucepls has been open on your fork since May with the window move dispatchers,
which is where I was about to start. I would rather build on it than duplicate it — is it waiting
on anything?

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.

2 participants