Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

lock

The session lock: whether it is held, authentication progress and the last failure.

The lock screen itself is a lock surface; this capability locks the session and reports the password attempt.

button {
    on_click = function() mantle.lock:lock() end,
    children = { text { content = "Lock" } },
}

State

mantle.lock:get() returns LockState, nil before the first push. A field marked ? may be absent.

mantle.lock’s payload.

FieldTypeDescription
activebooleanThe Renderer confirmed the session locked; a requested lock stays false until then.
attemptsintegerRejected passwords since this lock was confirmed; reset by the next lock.
authenticatingbooleanA password is with PAM. A second submit is refused while true.
errorstringLast failure to draw: PAM’s verdict ("authentication failed", "too many attempts", or a PAM or worker error) or a refused lock’s reason. Cleared by a correct password, lock, a confirmed lock, and unlock.
unlockingbooleanPAM said yes and the lock is still up: the window for an out-animation.

Actions

Call each as mantle.lock:<action>(arguments...); ? marks an argument you may omit.

mantle.lock actions. There is no unlock; only a correct password unlocks.

ActionArgumentsDescription
lockLocks the session; a no-op while active.
set_unlock_animationms?: integerKeeps the lock up ms after a correct password for an out-animation. Clamped to 600; omitted is 0.

Backend

ContractBehavior
OwnershipThe Supervisor decides lock and unlock; the Renderer holds and paints ext_session_lock_v1. Built at boot, unlike other capabilities
TriggersThe lock action, and logind’s Lock signal (loginctl lock-session). logind’s Unlock is logged and ignored. Each lock and unlock sets logind’s LockedHint
UnlockOnly a successful PAM conversation, run in a re-exec’d worker with the mantle PAM service from /etc/pam.d or /usr/lib/pam.d, else login. An exchange that takes over 30 s fails
Unlock animationset_unlock_animation delays the release by up to 600 ms; the value persists across reloads
CrashA dead Renderer never unlocks; the replacement retakes the lock. $XDG_RUNTIME_DIR/mantle/session-locked carries the lock across a Supervisor restart
Refused or lostSets mantle.rescue with the reason
ReloadAn edit that would recreate a lock surface is refused while locked (lock surface)

How do I…

TaskAnswer
Show “wrong password”error and attempts: lock surface example
Animate the lock screen outset_unlock_animation with the animation’s length, then drive the fade from unlocking: Lock screen recipe

Gotchas

TrapFix
Removing set_unlock_animation from the config keeps the old delayThe value outlives reloads. Call set_unlock_animation with no argument to reset it to 0
A 1 s out-animation is cut shortThe delay clamps to 600 ms. Keep the animation within it

See also: Lock screen recipe; idle to lock after inactivity.

Source: supervisor/src/capabilities/lock/