Skip to content

Wait for apps to flush state before powering off or rebooting - #9520

Open
reverb256 wants to merge 1 commit into
omacom:quattrofrom
reverb256:fix/close-all-wait-before-poweroff
Open

Wait for apps to flush state before powering off or rebooting#9520
reverb256 wants to merge 1 commit into
omacom:quattrofrom
reverb256:fix/close-all-wait-before-poweroff

Conversation

@reverb256

Copy link
Copy Markdown

Fixes #7085

Problem

omarchy shutdown / omarchy reboot arm the poweroff/reboot timer in the user
manager before dispatching close-all, and the previous close-all fired the
close requests and immediately returned (sleep 1 was the only grace period).
Closing is asynchronous: apps like browsers write their session state only after
the WM forwards the close request. With 2s to poweroff and no wait, heavy
sessions were killed mid-write and lost state on the next launch — exactly the
"close, wait for exit, then reboot" workaround the reporter verified.

Fix

  • omarchy-hyprland-window-close-all --wait — new optional flag: after
    dispatching close requests, poll hyprctl clients until the list empties.
    Bounded (OMARCHY_CLOSE_ALL_TIMEOUT, default 10s) so a window that refuses
    to close cannot stall a shutdown. Plain invocations (e.g. the Ctrl+Alt+Delete
    "Close all windows" keybind) keep their instant behavior.
  • omarchy-system-shutdown / omarchy-system-reboot — arm the timer at 15s
    (past the 10s wait budget) and call close-all --wait, dropping the old
    1s sleep.

Tests

  • hyprland-window-close-all-test.sh — extended with a mock whose client list
    empties after N polls: asserts the plain path doesn't wait, --wait polls
    until windows exit, and a stuck window still completes within the timeout.
  • system-shutdown-test.sh — new: pins the invariant that both scripts arm
    their timers past the close-all wait timeout.

All 8 assertions pass; bash -n and ./test/cli are clean.

Shutdown and reboot armed the poweroff timer in the user manager before
closing windows, so a heavy session (e.g. browsers writing their session
on close) was killed mid-write. The close-all step now waits -- bounded,
10s by default -- for windows to actually exit, and the armed timers are
scheduled past that wait.

Fixes omacom#7085

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Multi-window session not fully restored after reboot — close-all does not wait for apps to exit

1 participant