Wait for apps to flush state before powering off or rebooting - #9520
Open
reverb256 wants to merge 1 commit into
Open
Wait for apps to flush state before powering off or rebooting#9520reverb256 wants to merge 1 commit into
reverb256 wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7085
Problem
omarchy shutdown/omarchy rebootarm the poweroff/reboot timer in the usermanager before dispatching close-all, and the previous
close-allfired theclose requests and immediately returned (
sleep 1was 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: afterdispatching close requests, poll
hyprctl clientsuntil the list empties.Bounded (
OMARCHY_CLOSE_ALL_TIMEOUT, default 10s) so a window that refusesto 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 old1s sleep.
Tests
hyprland-window-close-all-test.sh— extended with a mock whose client listempties after N polls: asserts the plain path doesn't wait,
--waitpollsuntil windows exit, and a stuck window still completes within the timeout.
system-shutdown-test.sh— new: pins the invariant that both scripts armtheir timers past the close-all wait timeout.
All 8 assertions pass;
bash -nand./test/cliare clean.