u/44-65-72-65-6b

Any way to have a bind call multiple dispatches at once?

I'm trying to make a bind that will close all windows in my active workspace, this is what I came up with.

hl.bind(mod .. "+ SHIFT + W", function()
    for i, window in ipairs(hl.get_windows({ workspace = hl.get_active_workspace() })) do
        hl.timer(function()
            hl.dispatch(hl.dsp.window.close(window))
        end, { timeout = i * 50, type = "oneshot" })
    end
end)

Only thing that's throwing me off is how I needed to include the timer in it, calling window.close directly in the for loop-

hl.bind(mod .. "+ SHIFT + W", function()
    for _, window in ipairs(hl.get_windows({ workspace = hl.get_active_workspace() })) do
        hl.dispatch(hl.dsp.window.close(window))
    end
end)

-causes only one window to close rather than all of them.

So is there a way to do this without timer or is this my best bet?

reddit.com
u/44-65-72-65-6b — 3 days ago