Window.close() not working in called function

Hyprland version

Hyprland 0.55.1 built from branch v0.55.1 at commit a47147bc095e5b3be3eb8bd04f0ac242b968cd4d clean ([gha] Nix: update inputs).
Date: Wed May 13 22:55:46 2026
Tag: v0.55.1, commits: 7311

Libraries:
Hyprgraphics: built against 0.5.1, system has 0.5.1
Hyprutils: built against 0.13.1, system has 0.13.1
Hyprcursor: built against 0.1.13, system has 0.1.13
Hyprlang: built against 0.6.8, system has 0.6.8
Aquamarine: built against 0.11.0, system has 0.11.0

Version ABI string: a47147bc095e5b3be3eb8bd04f0ac242b968cd4d_aq_0.11_hu_0.13_hg_0.5_hc_0.1_hlg_0.6
no flags were set

Describe your issue / feature…

So I was trying to get this to work:

local function safe_close_window(graceful)
    local active = hl.get_active_window()
    if graceful then
        hl.dsp.window.close()
        hl.notification.create({text="closing window", duration="1000"})
    else
        hl.dsp.window.kill(hl.get_active_window())
        hl.notification.create({text="killing window", duration="1000"})
    end
end

hl.bind("SUPER + Q", function() safe_close_window(true) end)
hl.bind("SUPER + SHIFT + Q", function() safe_close_window(false) end)

After messing with this for quite a while I realized that the call to hl.dsp.window.close() does not do anything in this function here. Why is that? If I instead use

hl.bind("SUPER + Q", hl.dsp.window.close())

it closes the window as expected.

Any idea what I’m doing wrong?

Thanks!

When you wrap a function, you have to actually call the .dsp. functions.
So:

hl.dispatch(hl.dsp.window.close())

ah, I see. Thank you so much!

It didn’t initially ring any bells when I read about these functions being supposed to be fed into .bind() or .dispatch() directly :upside_down_face: