Class SessionLock
The lock screen, as wm.session_lock.
The config doesn't lock the session itself. A lock client such as swaylock does, usually started from a key binding:
lua
wm.session_lock:set_backdrop_color("#1d2021")
wm.input:on("key", function(event)
if event.state == "Pressed" and event.modifiers.super and event.raw_key == Key.l and not wm.is_session_locked then
Process.spawn("swaylock", {})
end
end)While the session is locked or locking:
- Hazel draws only the lock client's surfaces on a backdrop, and the cursor.
- Pointer and keyboard go to the lock client.
seat:focusdoes nothing. - Input events still reach the config first.
prevent_default()keeps one from the lock client. - A second lock client is turned away, unless the first one died after locking. The session then stays locked on the backdrop until a new one takes over.
When the lock client unlocks, no seat has keyboard focus. Give it back in wm's session_unlocked event:
lua
wm:on("session_unlocked", function()
local top = wm.windows:get(wm.windows:count())
if top and top.box.visible then wm.input.seats:get(1):focus(top) end
end)Methods
wm.session_lock:state() -> "unlocked" | "locking" | "locked"state
Where the lock is.
"locking": a lock client has asked, and not every output shows a lock surface that has drawn yet."locked": every output does.session_lockedfires on the change.wm.is_session_lockedis true in both.
lua
local fully_locked = wm.session_lock:state() == "locked"wm.session_lock:surfaces() -> LockSurface[]surfaces
The lock client's surfaces that still exist, usually one per output. Each is the size of its output.
- Empty when unlocked.
wm.session_lock:set_backdrop_color(color: string) -> nilset_backdrop_color
The colour behind the lock surfaces, as #rrggbb or #rrggbbaa. It shows on an output until its lock surface draws, and everywhere if the lock client dies.
- Default: black.
- It stays set across locks and reloads.
Errors for any other colour format.