Skip to content

Schedule logout with systemd-run like reboot and shutdown - #12254

Closed
z23 wants to merge 6 commits into
omacom:quattrofrom
z23:fix/logout-systemd-run
Closed

z23 wants to merge 6 commits into
omacom:quattrofrom
z23:fix/logout-systemd-run

Conversation

@z23

@z23 z23 commented Sep 17, 2026 •

Copy link
Copy Markdown

This proposal scheduled logout outside the terminal that requested it. Current quattro implements that behavior in the consolidated bin/omarchy-system command, introduced by #15231 (4bf51ed1). It runs logout, reboot and shutdown in bounded user services and waits for application exit with a deadline.

Merged current quattro in e77d912d, resolving the obsolete logout-script modify/delete conflict by keeping upstream's consolidated implementation and its tests. The resulting branch has zero file differences from quattro; this PR is superseded by #15231.

Validation: the system-power suite passes, including logout scheduling, caller-environment forwarding, bounded window cleanup, failed scheduling, rejected exit requests and command routing. The full CLI suite also passes in the companion confirmation checkout at the same upstream revision. No live logout was initiated.

The earlier worker review did not reproduce the menu logout failure in #12233; this PR does not establish that issue as fixed.

nohup does not keep the delayed `uwsm stop` alive once the invoking
scope is reaped, so Logout closes windows and never ends the session.
@llstrk

llstrk commented Sep 25, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: The change is correct and brings logout in line with reboot and shutdown. uwsm stop now runs as its own transient unit in the systemd user manager, outside the caller's process tree. If scheduling fails, the script exits before the OSD and before any window is closed. One point remains open: the source does not show that this resolves the menu logout failure in #12233.

Reboot / shutdown Logout (base) Logout (this PR)
Scheduling systemd-run --user --collect --quiet --on-active=2s --timer-property=AccuracySec=100ms nohup bash -c "sleep 2 && uwsm stop" & same systemd-run flags as reboot / shutdown
Where the delayed action runs own user-manager unit child of the calling process own user-manager unit
Scheduling failure exit before OSD and window closing not detected; windows still closed exit before OSD and window closing

Verified (repository test): In an isolated sandbox, test/shell.d/system-power-test.sh passes on the PR head. It fails as expected against the base logout script and when || exit 1 is removed from the new logout script.

"Fixes #12233" is not demonstrated for the menu path

The PR description attributes the failure to the invoking systemd scope being reaped when the script exits or the terminal closes. On the path reported in #12233 (menu > System > Logout), the source does not show any step that would kill the old delayed job:

uwsm start ... hyprland.desktop
└─ wayland-wm@hyprland.desktop.service   (compositor unit)
   └─ Hyprland: hl.exec_cmd("omarchy-launch-shell")      fork + exec, no new unit
      └─ systemd-cat -- quickshell                         execs, no new unit
         └─ Util.execDetached -> bash -lc omarchy-system-logout
            └─ nohup bash -c "sleep 2 && uwsm stop" &    (base script)
               stays in the compositor unit's cgroup; no terminal scope involved

A systemd scope is not stopped when one of its processes exits. It stays alive while any process remains in it. Closing the other windows does not stop the compositor unit either. On this path the base job should therefore survive to run uwsm stop, so the actual cause of #12233 is still unknown. The new scheduling removes any dependence on the caller's lifetime and is sound hardening for other contexts, such as a terminal whose scope is stopped. It would not help if uwsm stop runs and then fails to stop the compositor.

Impact: Closing #12233 on the basis of this PR could leave the reported failure in place if its cause lies outside the caller-lifetime class.

Suggested change: Confirm with one real menu logout on a disposable machine or VM before treating #12233 as fixed. Alternatively, on an affected system with the old script, journalctl -b -t uwsm shows "Stopping compositor..." only if the delayed uwsm stop ran. With the new script, journalctl --user -b -u 'run-*' shows the scheduled unit's output. A nested compositor session that shares the user's systemd user manager is not a safe test bed: uwsm stop would stop the outer session's compositor. The second sentence of the new code comment ("nohup only survives SIGHUP; ...") describes removed code and could be dropped, which would also match the reboot and shutdown comments.

Optional test improvement: The test mocks only systemd-run, omarchy-state, omarchy-hyprland-window-close-all and sleep. uwsm, systemctl and omarchy-osd resolve to the real commands. In the sandbox, running this test against the base logout script reached a real uwsm stop through the background nohup job. On a live desktop, the same run (for example to confirm the test fails on the base, or during git bisect) would end the session, and any run on an Omarchy desktop shows real "Logging out", "Rebooting" and "Shutting down" OSD toasts. Adding logging stubs for uwsm, systemctl and omarchy-osd to mock_bin would make such cases fail safely. It would also let the expected logs assert that the OSD follows scheduling and is skipped on failure.


Review information

Test scope: Source review of the pinned head 9c49736 against base quattro (9c5482c), including systemd systemd-run, timer, scope and service source (v258 and v261), uwsm v0.26.7 (the version in #12233), and the Hyprland and Quickshell spawn paths. The repository test ran in an isolated sandbox with no access to a user manager, session bus or desktop session. No real logout was performed, and the reporter's installed Hyprland, Quickshell and systemd builds and local session configuration were not examined.

AI process: Opus 5.5 Medium coordination and synthesis, independent Opus 5.5 Xhigh and GPT 6 Sol Xhigh technical assessments, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

Match the reboot comment, and stub uwsm, systemctl, and the OSD so the power tests cannot stop the session or toast the desktop.
@z23

z23 commented Sep 26, 2026

Copy link
Copy Markdown
Author

Thanks. The logout comment now matches reboot and shutdown, and the power test stubs uwsm, systemctl, and omarchy-osd (0056062). This no longer claims to fix #12233: the menu path is Quickshell.execDetached inside the compositor cgroup, so a dying terminal scope does not explain that report.

@omarchybot omarchybot added the bug Something isn't working label Sep 27, 2026
@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Follow-up to the earlier review and the author reply, checked at 0056062e.

Outcome: 0056062e addresses the earlier points in content. The same commit removes the executable bit from bin/omarchy-system-logout, so the PR's own power test now fails on a clean checkout and omarchy logout no longer resolves from a checkout. GitHub also still links #12233 as an issue this PR closes.

Earlier point Status at 0056062e
Logout scheduling matches reboot and shutdown and aborts before the OSD and window closing on failure Still holds; the script's only content change is the comment
Repository test passes on the head No longer holds as committed (mode change below); passes with the mode restored
"Fixes #12233" not demonstrated for the menu path Resolved in the description; GitHub still links the issue (below)
Second code-comment sentence described removed code Resolved; the comment now matches reboot and shutdown
Optional test improvement: stub uwsm, systemctl, omarchy-osd Resolved

Verified: In an isolated sandbox, every backend the power test could reach (systemd-run, uwsm, systemctl, omarchy-osd, omarchy-state, omarchy-hyprland-window-close-all, sleep) resolves to the test's own stubs, and the expected logs now assert that the OSD follows scheduling. With the logout mode restored, the test passes and still fails against the base logout script, a copy without || exit 1, and a copy that shows the OSD before scheduling.

bin/omarchy-system-logout is no longer executable

0056062e changes both files from 100755 to 100644. The test file's mode does not matter (test/shell runs it with bash), but the logout script is executed directly:

                                  9c497363                   0056062e
bin/omarchy-system-logout mode    100755                     100644
system-power-test.sh logout case  ok                         Permission denied, then not ok
omarchy logout --help             prints help                exit 127, Unknown Omarchy command
omarchy system --help             lists logout               no logout entry

The quattro tip matches 9c497363 on the mode and both dispatcher rows (its test has no logout case). bin/omarchy only considers files that pass -x (load_commands, resolve_direct_route). In the sandbox, restoring only the mode on otherwise identical content makes the test and the dispatcher cases pass again, on the head and on a trial merge into the quattro tip.

Impact: ./test/shell reports system-power-test.sh as failed. On a dev-linked checkout, where $OMARCHY_PATH/bin comes first on PATH, omarchy logout and omarchy system logout fail as shown. From source and bash command lookup (not tested in a live session), Menu > System > Logout would skip the checkout copy and run a packaged /usr/bin/omarchy-system-logout if one is installed (in current packages, the older nohup version), or fail otherwise. Packaged installs are not affected: the omarchy PKGBUILDs install bin/* with install -Dm755.

Suggested change: Run git update-index --chmod=+x bin/omarchy-system-logout test/shell.d/system-power-test.sh and commit. git ls-tree HEAD bin/omarchy-system-logout should then show 100755.

#12233 is still linked as closed by this PR

The PR's closingIssuesReferences currently lists #12233, so GitHub still treats it as an issue this PR closes. The rewritten description says "...so it does not close #12233", and "close #12233" matches GitHub's closing-keyword syntax, which does not account for the "not". A link left over from the original "Fixes #12233" is also possible.

Impact: Merging into quattro, the default branch, would likely close #12233 while the menu logout failure remains unexplained, which is the outcome the earlier review pointed to.

Suggested change: Reword without a closing keyword directly before the reference, for example "#12233 should stay open until the menu path is confirmed", then check that the Development sidebar no longer lists #12233. If it still does, unlink it there.

Related open PRs: #11151 changes the same failure loop in test/shell.d/system-power-test.sh to expect two systemd-run attempts (user manager, then a system-manager fallback), which fits reboot and shutdown there. A three-way merge of the two versions of the test has no textual conflict, but the merged loop also runs logout, which makes one attempt. A sandboxed run of the merged test, with the logout mode restored, fails on the logout case. Whichever PR lands second would need a per-action expected count. #12575 and #7216 also add an omarchy-osd stub and conflict textually in this file. #13076 conflicts in the same file and schedules shutdown without --on-active=2s, so if it lands first, logout would no longer use the same flags as shutdown.


Review information

Test scope: Follow-up source review of 0056062e against the earlier head 9c497363, base 9c5482c and quattro tip 3faafba, including bin/omarchy command discovery, the test runner and the omarchy PKGBUILDs. The power test, dispatcher help commands and trial merges with the quattro tip and with #11151 ran in an isolated sandbox with all backends stubbed. No real logout or dev-linked session was tested. The #12233 link was read from the GitHub API.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@z23

z23 commented Sep 28, 2026

Copy link
Copy Markdown
Author

Thanks for catching both of these. Fixed in ee3b168.

  • Restored mode 100755 on the logout script and power test, in both the index and working tree. The power test passes all six checks, and omarchy logout --help resolves again.
  • Reworded the description to say that omarchy-system-logout closes windows but never actually logs out #12233 should stay open until the menu path is confirmed, without a closing keyword before the reference. GitHub now reports an empty closingIssuesReferences list.

The related-PR notes are useful. I have kept this branch's one-attempt logout expectation; if #11151 lands first, the combined test needs per-action counts. I have not folded the other scheduling changes into this PR or tested a live logout.

@llstrk

llstrk commented Sep 29, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: No defects found.

Follow-up to the second review and the author reply, checked at ee3b1684. It restores mode 100755 on both files without changing their content, and the reply's claims check out.

Earlier point Status
Logout script not executable Resolved
#12233 linked as closed Resolved
Power test passes Holds again
Scheduling, wording, comment, stubs Unchanged
#11151, #12575, #7216, #13076 Unchanged: the #11151 combined test still fails on logout; #7216 now labeled ready

#10353, #7501 and #7434 also conflict in the logout script (below).

Verified
  • git diff --raw 0056062e ee3b1684: both files 100644 to 100755, same blobs (a88f206e, 29bbe062). The PR no longer changes any mode relative to the base.
  • bash test/shell.d/system-power-test.sh exits 0 with six ok lines. It still fails with the base nohup logout script and with a copy without || exit 1.
  • omarchy logout --help and omarchy system logout --help print the logout help; omarchy system --help lists omarchy system logout.
  • closingIssuesReferences is empty.
  • quattro moved from 3faafba to b421b1b4 without touching bin/omarchy, the power scripts, the power test or test/shell. The trial merge has no conflicts and the test passes on it.
Reproducer (passes at ee3b168)

Checks at ee3b168. git ls-tree ran on a plain clone. The test and help commands ran in an isolated sandbox on a read-only snapshot of the committed tree, with systemd-run, uwsm, systemctl and loginctl shadowed by logging stubs that exit 1 (none was called):

git ls-tree ee3b1684 bin/omarchy-system-logout test/shell.d/system-power-test.sh
bash test/shell.d/system-power-test.sh; echo "exit=$?"
bin/omarchy logout --help; echo "exit=$?"

Actual output:

100755 blob a88f206eac252533a789c5fc0f2b2afd36ee168a	bin/omarchy-system-logout
100755 blob 29bbe062ed6af4ce6d3a1a875006ff7101daaede	test/shell.d/system-power-test.sh

ok - reboot runs after being scheduled outside the terminal scope
ok - shutdown runs after being scheduled outside the terminal scope
ok - logout runs after being scheduled outside the terminal scope
ok - reboot leaves state and windows alone when scheduling fails
ok - shutdown leaves state and windows alone when scheduling fails
ok - logout leaves state and windows alone when scheduling fails
exit=0

Usage:
  omarchy system logout

Log out after closing application windows

Examples:
  omarchy logout
  omarchy system logout

Aliases:
  omarchy logout

Binary:
  omarchy-system-logout
exit=0

omarchy system logout --help prints the same help (exit 0), and omarchy system --help lists omarchy system logout. At 0056062 the same commands give Permission denied then not ok - logout runs after being scheduled outside the terminal scope, and Unknown Omarchy command: omarchy logout --help (exit 127).

Negative controls at ee3b168 (same test, only bin/omarchy-system-logout replaced, mode 755):

  • base (nohup) logout script: fails with not ok - logout runs after being scheduled outside the terminal scope.
  • current script without || exit 1: fails with not ok - logout aborts when scheduling fails.

Trial merge of ee3b168 into quattro b421b1b: no conflicts, both files stay 100755, same six ok lines.

Related open PRs
Reproducer (#11151 merged test)

Merge this PR (ee3b168) and #11151 (901d9aa) onto quattro (b421b1b). The merge has no textual conflict, in either order, and gives the same tree. Then run the power test the way test/shell runs it. The test stubs systemd-run, uwsm, systemctl and omarchy-osd, so nothing is scheduled.

git fetch origin quattro pull/12254/head:pr-12254 pull/11151/head:pr-11151
git checkout --detach origin/quattro
git merge --no-edit pr-12254
git merge --no-edit pr-11151
bash test/shell.d/system-power-test.sh; echo "exit=$?"

Actual output (isolated sandbox, merged tree of b421b1b + ee3b168 + 901d9aa):

ok - reboot runs after being scheduled outside the terminal scope
ok - shutdown runs after being scheduled outside the terminal scope
ok - logout runs after being scheduled outside the terminal scope
ok - reboot leaves state and windows alone when scheduling fails
ok - shutdown leaves state and windows alone when scheduling fails
systemd-run --user --collect --quiet --on-active=2s --timer-property=AccuracySec=100ms uwsm stop
not ok - logout leaves state and windows alone when scheduling fails
exit=1

The merged failure loop is for action in reboot shutdown logout with #11151's != 2 line count. Logout makes one systemd-run --user attempt, so its log has one line.


Review information

Test scope: Source review and sandboxed tests with all backends stubbed, at ee3b1684 and on a trial merge into quattro b421b1b4; no live logout.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at ee3b1684, against quattro at 8b4eae66. The change is sound, but the bug it fixes did not reproduce, so this is not marked verified.

What ran, on a disposable Omarchy worker with a live Hyprland session:

  • test/shell.d/system-power-test.sh passes 6 of 6 on the head, and ./test/cli passes.
  • The quattro logout script, run from a terminal launched the way Omarchy launches one (uwsm-app, which puts it in its own scope under app-graphical.slice), logged out. The delayed bash -c "sleep 2 && uwsm stop" outlived the terminal closing and the journal shows it stopping the compositor. Same result in foot and in Ghostty.
  • The same script launched by the compositor itself, the way the menu runs it inside wayland-wm@hyprland.desktop.service, also logged out.
  • The script on this branch logged out from foot too: uwsm stop ran from its run-* transient unit and found the compositor.

So on a stock install the nohup job is not killed. A scope stays up while any process is left in it, and closing windows does not stop it. This branch makes logout match reboot and shutdown, and || exit 1 now stops the script before the OSD and before windows close if scheduling fails. That is consistency and hardening rather than a demonstrated fix. It also means the menu failure in #12233 has a cause elsewhere, since that path worked on the worker with the old script.

Second opinion: Codex at medium effort reviewed the diff. It found no defect and, like me, could not name a stock context where the old job gets killed. It agrees with what was already written here, and its independence is not guaranteed. It also noted that the test checks the scheduling call, not the timer running, which is what the worker run above covered.

Next: waiting on the maintainer to decide whether to take this for consistency with reboot and shutdown without a reproduced failure. Nothing is needed from the author.

@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 4/5

[Medium risk] Changes how the logout command schedules its shutdown sequence.

The PR appears safe to merge, with a non-blocking gap in coverage of the scheduled logout backend.

Findings

  1. P2 Logout backend goes untested ▶

Summary

The PR moves logout scheduling from a background shell into a delayed user-manager service and aborts before closing windows if scheduling fails.

  • Extends power-command tests to check logout scheduling and scheduling failure.

Reviews (1) · Last reviewed commit: "Describe logout scheduling without claim..."

Comment thread test/shell.d/system-power-test.sh Resolved
@z23

z23 commented Oct 5, 2026

Copy link
Copy Markdown
Author

Thank you for testing both the terminal and menu paths. I’ve taken the distinction between a consistency improvement and a reproduced bug fix: the description and source comment now make that clear, and #12233 remains open.

Current quattro is merged in bc29b70f, with the conflict resolved by preserving the newer inhibited-shutdown and blocked-window tests and adding the logout checks alongside them. 57fccf9e clarifies the scheduling comment. The resulting PR changes only the logout command and its coverage relative to quattro.

The power test passes all 11 assertions, the CLI suite passes all 117 assertions, and metadata, syntax and diff checks pass. No live logout was initiated. Whether to take this scheduling consistency change remains the maintainer’s decision.

@omarchybot omarchybot added enhancement New feature or request and removed bug Something isn't working labels Oct 7, 2026
@z23 z23 closed this Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants