- Lock the session from the power button or `chandra-ctl lock` - Unlock with a face or the password; the password always works - Add compositor lock module with tests, and a polkit unlock policy (org.chandra.unlock) - Document the lock flow in docs/lock.md and link it from the README - Add generated interface bindings for the compositor and widget components
4.1 KiB
Locking the screen
Chandra can lock the session: the desktop is hidden and nothing but the unlock prompt gets input until a face (or, as the fallback, your password) lets you back in. It reuses the password dialog (auth-dialog.md) and face unlock (face-unlock.md), so there is no second lock UI to configure.
Turn it on
Locking on screen-off is off by default so a half-set-up machine can't lock you out. Turn it
on by setting CHANDRA_LOCK=1 in the session environment or toggling it at runtime via
chandra-ctl lock on-blank on; then pressing the power button (or chandra-ctl screen off) to
blank the screen also locks it, and waking the screen asks for your face or password.
chandra-ctl lock locks immediately, regardless of the setting (handy to bind to a key or a
panel button).
chandra-ctl lock # lock now
chandra-ctl lock status # locked | unlocked
chandra-ctl lock on-blank on # arm lock-on-blank at runtime (on | off | status)
Before you enable it, make sure you can get back in: enroll a face
(chandra-face enroll, or Settings > Session > Face unlock) and/or confirm your login password
works, and that face unlock is in the polkit-1 PAM stack (chandra-face pam enable polkit-1,
which just install --pam does). If neither the camera nor the password can authenticate, the
session stays locked and only an SSH login can recover it.
How it works
power off / chandra-ctl lock
│
▼
compositor: locked ──"unlock"──► chandra-polkit-agent
• hides windows/panel │ CheckAuthorization(unix-process, org.chandra.unlock)
• swallows input ▼
• dark lock backdrop polkit ──► this agent's dialog: face (PAM), then password
• draws the unlock dialog │
▲ │
└────────── "unlocked" ◄──────┘ (success) "unlock-failed" ◄── (cancel / fail)
- Locking is in
compositor/host/lock.mbt. The power button (compositor/host/compositor.mbt,handle_input_inner, key116) andchandra-ctl screenroute throughset_manual_screen_offincompositor/host/power.mbt;lock_on_blank(fromCHANDRA_LOCKorchandra-ctl lock on-blank) decides whether blanking also locks. Blanked again while unlock is in flight, the compositor sendscancel-unlockso polkit and the camera stop immediately. While locked,build_scenehides windows, popups, desktop widgets, and the panel behind a dark"Screen locked"backdrop, andhandle_input_innerswallows input (re-raising unlock only on a key or button press when no dialog is up). - Unlocking runs in the polkit agent
(
compositor/polkit/agent_loop.mbt,agent.mbt): once registered with polkit, on anunlockmessage it passes aunix-processsubject (pid,start-time,uidfrom/proc) toCheckAuthorizationfororg.chandra.unlockwithAllowUserInteraction(and cancels viaCancelCheckAuthorizationoncancel-unlock). polkit then drives the agent's own dialog, and because thepolkit-1PAM stack carriespam_chandra_face.sothe camera is tried first, with the password as the fallback. The action isauth_self(never_keep), so it prompts every time and nothing is cached. - The policy file is
compositor/polkit/org.chandra.unlock.policy, installed to/usr/share/polkit-1/actions/bysession/install.py.
Limits (today)
- Lock-on-idle isn't wired yet — only the power button,
chandra-ctl screen off, andchandra-ctl locklock. (The idle timeout still blanks the screen without locking.) - The idle lock backdrop is a minimal padlock card ("Screen locked") rather than a custom clock or wallpaper clock widget.
- Cancelling the unlock prompt keeps you locked (the desktop stays hidden); the next key press or screen tap raises the prompt again.