Decide how to log out by what the session is, not what is installed

The power menu's Log Out ran `uwsm stop` whenever the uwsm binary existed --
which is always, since Panama installs it. In a plain "Hyprland" session there
is no uwsm unit to stop, so the command failed and the button silently did
nothing. Nor is `uwsm check is-active` the test: it reads
graphical-session.target, which the plain session also activates. The one
thing unique to a managed session is uwsm's own compositor unit,
wayland-wm@*.service, so that is now what chooses between stopping the unit
and asking the compositor to exit. A new contract pins the decision -- and
checks the script line rather than the file, because the comment explaining
the wrong tests has to be allowed to name them.

Claude-Session: https://claude.ai/code/session_01Epx9ZC1gwm81K3jm9x9CKh
This commit is contained in:
Gabriel Brown
2026-08-23 10:38:09 -04:00
parent 12f6b2a310
commit 6ad2e017e8
2 changed files with 54 additions and 4 deletions
@@ -31,10 +31,15 @@ PanelWindow {
property int currentIndex: 0
// The session is uwsm-managed, so logging out means stopping the uwsm unit
// rather than killing the compositor; the hyprctl branch is only there for
// a session started without it.
readonly property string logoutScript: 'if command -v uwsm >/dev/null 2>&1; then exec uwsm stop; else exec hyprctl dispatch "hl.dsp.exit()"; fi'
// A uwsm-managed session logs out by stopping the uwsm unit; a plain
// "Hyprland" session must ask the compositor to exit instead. The branch
// used to test merely that the uwsm BINARY existed -- but uwsm is always
// installed here, so in a plain session `uwsm stop` found no unit to
// stop, failed, and the button did nothing. Nor is `uwsm check is-active`
// the test: it only checks graphical-session.target, which the plain
// session also reaches. What only the managed session has is uwsm's own
// compositor unit, wayland-wm@*.service, so that is what decides.
readonly property string logoutScript: 'if systemctl --user list-units --no-legend --state=active "wayland-wm@*.service" 2>/dev/null | grep -q .; then exec uwsm stop; else exec hyprctl dispatch "hl.dsp.exit()"; fi'
readonly property var entries: [
{