feat(power): logout via loginctl, not Niri-locked

Default `loginctl terminate-session $XDG_SESSION_ID`; `logout_command`
TOML override for other compositors.
This commit is contained in:
2026-06-17 12:40:24 +02:00
parent 115cfe6bb1
commit 7dae48f6cc
10 changed files with 225 additions and 46 deletions
+8
View File
@@ -106,3 +106,11 @@ Architectural and design decisions for Moonset, in reverse chronological order.
- **Why**: Moonarch is built exclusively for the Niri compositor. Generic Wayland logout mechanisms don't exist — each compositor has its own.
- **Tradeoffs**: Hard dependency on Niri. If the compositor changes, `power::logout()` must be updated.
- **How**: `Command::new("/usr/bin/niri").args(["msg", "action", "quit"])`.
- **Superseded by** the 2026-06-17 entry below.
## 2026-06-17 Compositor-agnostic logout via `loginctl terminate-session`
- **Who**: ClaudeCode, Dom
- **Why**: Reverses the 2026-03-27 decision. Hardcoding `niri msg action quit` made logout the only compositor-locked action (lock/hibernate/reboot/shutdown were already agnostic via moonlock/systemctl). There is no Wayland protocol for "end session", but systemd-logind sits one layer below and offers a portable mechanism.
- **Tradeoffs**: `loginctl terminate-session` SIGTERMs all session processes rather than letting the compositor quit itself — functionally equivalent for logout. Requires a logind session (verified: greetd's PAM chain loads `pam_systemd`, which sets `XDG_SESSION_ID`). Niri's own quit command remains available via the override.
- **How**: `power::logout()` resolves a command — TOML `logout_command` override (space-separated) if set, else `/usr/bin/loginctl terminate-session $XDG_SESSION_ID`. Errors with a hint to set `logout_command` when no session id is present.