Keybinds: the close bind closes a sheet, not the window behind it

A Lucid sheet that holds the keyboard (the keybinds sheet, What's new, the
session menu, the switcher, polkit) sits over the focused window, but
Hyprland's binds still reach that window: SUPER+C over the keybinds sheet
left the sheet up and closed the window under it. The close bind now looks
for a layer with exclusive keyboard focus first, closes the sheet it knows,
and never the window while one is up. It lives in binds.lua so existing
keybinds.json files get it too.

Fixes #113
This commit is contained in:
Ciro Rivera
2026-11-16 02:25:20 -06:00
Unverified
parent d1bcf8a69d
commit 48bfdb1a37
+20
View File
@@ -69,6 +69,25 @@ local function fill(s, n, key)
return (string.gsub(string.gsub(s, "{n}", tostring(n)), "{key}", tostring(key)))
end
-- a Lucid sheet holding the keyboard (exclusive layer) sits over the focused
-- window, so the close bind meant the sheet: close it, never the window behind
local SHEETS = {
lucidkeybinds = "keybinds", lucidwhatsnew = "whatsnew", ["lucid-session"] = "session",
["lucid-switcher"] = "switcher", lucidpolkit = "polkit",
}
local function close_over_sheet(close)
return function()
for _, l in ipairs(hl.get_layers()) do
if l.mapped and l.keyboard_interactivity == 1 then
local target = SHEETS[l.namespace]
if target then hl.dispatch(hl.dsp.exec_cmd("qs ipc call " .. target .. " close")) end
return
end
end
if type(close) == "function" then close() else hl.dispatch(close) end
end
end
local function bind_one(entry, n, key)
local keys = fill(entry.keys, n, key)
if type(keys) ~= "string" or keys == "" then error("no keys", 0) end
@@ -82,6 +101,7 @@ local function bind_one(entry, n, key)
action = hl.dsp.exec_cmd(cmd)
end
if entry.id == "close" then action = close_over_sheet(action) end
local opts = {}
if type(entry.opts) == "table" then
for k, v in pairs(entry.opts) do opts[k] = v end