Skip to content

Prevent lid closure from interrupting reboot - #14248

Open
chemineer1 wants to merge 5 commits into
omacom:quattrofrom
chemineer1:codex/reboot-lid-inhibit
Open

chemineer1 wants to merge 5 commits into
omacom:quattrofrom
chemineer1:codex/reboot-lid-inhibit

Conversation

@chemineer1

@chemineer1 chemineer1 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Closing the lid while Omarchy prepares to reboot can suspend the laptop. This extends the shutdown protection introduced in #13076 to standard reboot and reboot to firmware setup, using the same sleep:idle:handle-lid-switch inhibitor from before applications close through the power request. The inhibitor reason uses the localized progress message. Logout remains uninhibited.

Validation at b0a11abd, reported by omarchybot:

  • All 24 power tests, 4 window-close tests, and 136 CLI checks pass. Tests require inhibition for both reboot types. The focused power suite fails against upstream.
  • Checks using real systemd with power and desktop commands stubbed confirm inhibition before both reboot requests and cleanup afterward. Shutdown remains inhibited; logout does not acquire an inhibitor.

A standard reboot with the lid closed completed without suspending on a Dell XPS 13 (DX13260) at the earlier revision 94f27639. Reboot to firmware setup has not been tested on hardware.

@greptile-apps

greptile-apps Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues remain.

Summary

Extends the existing lid and sleep inhibitor to reboot and firmware reboot. Logout remains uninhibited.

  • Reboots stay protected from lid closure until the power request returns.

Reviews (6) · Last reviewed commit: "Merge quattro: keep the firmware reboot ..." · Reviewed by Greptile

Comment thread bin/omarchy-system-reboot Resolved
Comment thread bin/omarchy-system-reboot Resolved

@chessing234 chessing234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head d3e8d51bb093eaed80ff152b0f611d7b95eea006.

Reviewed detached scheduling, inhibitor scope, checkout preservation through $0, and independent OSD/preparation dispatch. The focused harness exercised the command wiring, but some test stubs refer to Linux-only /usr/bin/sleep, so this is not native timing/inhibition validation. No additional verified production defect found.

@chemineer1

Copy link
Copy Markdown
Contributor Author

@greptileai Please re-review the current revision and refresh the summary. The OMARCHY_PATH finding was withdrawn, and the OSD preparation issue was fixed in d3e8d51.

@omarchybot

Copy link
Copy Markdown
Collaborator

Read the diff at d3e8d51b against current quattro. Nothing was run and no labels were added: classifying needs two models to agree, and the second opinion (Codex Medium) was unavailable today because its daily review budget is spent. So this one is unclassified for now, and comes round again once the second opinion can run.

What reading it found:

  • The bug is still there on quattro. Exit sessions as soon as applications finish closing #15231 folded bin/omarchy-system-reboot and bin/omarchy-system-shutdown into one bin/omarchy-system. That script wraps only shutdown in systemd-inhibit --what=sleep:idle:handle-lid-switch; reboot and the new reboot-boot-menu still run exit_session without it, so closing the lid during the grace period can still suspend and leave the reboot refused.
  • This branch no longer merges. Both files it edits were deleted on quattro by Exit sessions as soon as applications finish closing #15231, so the fix has to move into bin/omarchy-system. There the change is small: run the --execute branch through systemd-inhibit for every action except logout, with a --why matching the action, and extend test/shell.d/system-power-test.sh to check reboot the way it already checks shutdown.
  • The OSD change does not carry across as it is. exit_session is shared by logout, reboot and shutdown now, and window closing waits on omarchy-hyprland-window-close-all --wait under a 2-second timeout. Running the OSD in the background there would change all three actions, which is the maintainer's call rather than part of the lid fix.
  • No other open pull request touches lid inhibition for reboot.

Next: waiting on a second opinion to settle the classification. After that, the port onto bin/omarchy-system can be verified on a worker.

@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 15, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed again at 94f27639, now that the fix lives in bin/omarchy-system on current quattro. Nothing found; this is labelled bug, verified and ready.

What was checked, on a disposable Omarchy worker with real systemd:

  • The bug, before and after. With systemctl reboot stubbed to list logind's inhibitors at the moment of the request, quattro's command makes both the reboot and reboot-boot-menu requests with no lid inhibitor held. This branch makes both under a sleep:idle:handle-lid-switch block inhibitor ("Rebooting"), and the inhibitor is gone once the request returns.
  • Tests. test/shell.d/system-power-test.sh passes 30 of 30 here and fails against quattro's bin/omarchy-system, so it catches the regression. hyprland-window-close-all-test.sh passes 4 of 4 and ./test/cli passes all 125 checks.
  • Read. Logout stays uninhibited. Shutdown's inhibitor reason is now the localized "Shutting down" rather than the fixed "Shutdown in progress", which changes only the description logind shows. Exit statuses still reach the failure notification.

Second opinion: Codex Medium reviewed the diff statically and found no defects. It agreed that the problem is real and that two production lines plus tests are proportionate. Its independence from this review is not guaranteed. It noted that the test mocks log arguments with $* and check only the English reason, which limits what they would catch later but is not a defect here.

No other open pull request adds lid inhibition to reboot. #11151 also edits bin/omarchy-system and the same test file, so whichever lands second will need a rebase.

Waiting on the maintainer.

@chemineer1

Copy link
Copy Markdown
Contributor Author

@greptileai A clarification on the OSD caveat in the latest summary for 94f27639:

The original finding concerned the reboot request overtaking OSD, state clearing, and window-close preparation in a background worker. The current consolidated exit sequence runs OSD, state clearing, and the bounded application-close wait sequentially before requesting reboot. That earlier race therefore does not carry over to this implementation. A slow OSD can still delay the sequence; this is existing behavior from #15231, and this PR preserves it while extending the shutdown inhibitor to both reboot actions. Please distinguish that inherited behavior from the resolved preparation race in the summary.

The physical lid-close test also passed on the current revision on October 15, using a Dell XPS 13 DX13260. The recorded script hash matches 94f27639:

  • The lid closed 0.886 seconds after service startup and 1.236 seconds before logind received the reboot request.
  • Logind accepted reboot 2.122 seconds after service startup, with the lid closed.
  • The expected sleep:idle:handle-lid-switch block inhibitor was recorded during preparation; systemctl returned zero, no intervening suspend was recorded, and the subsequent boot had a new boot ID.

The PR description now includes these results. This was one physical standard reboot on one laptop, with timestamp/inhibitor instrumentation; reboot-to-boot-menu remains covered by automated and real-systemd tests using harmless power stubs, rather than a physical test.

@greptile-apps

greptile-apps Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

That clarification is correct. The earlier OSD/state-clearing/window-close race does not apply to 94f27639: exit_session performs those steps sequentially, including the bounded application-close wait, before issuing either reboot request. A slow OSD can still delay reboot, but that is existing consolidated-exit behavior from #15231 and is preserved by this PR—not a new preparation race or a remaining finding.

The physical test supports the standard reboot path: it confirms the lid remained closed while the inhibitor was held and logind accepted the request without an intervening suspend. The reboot-to-boot-menu path remains covered by automated and real-systemd stub tests rather than a physical test.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Oct 18, 2026
quattro removed the reboot-boot-menu action (omacom#15795), so the lid inhibitor now covers reboot and shutdown, and the tests check reboot alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 18, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This stopped merging after #15795 removed the reboot-boot-menu action from bin/omarchy-system, so I merged quattro into the branch as 7c292e04. The only conflict was in test/shell.d/system-power-test.sh: the reboot-boot-menu cases are gone from the three loops that named it, and everything else in the branch is unchanged. The lid inhibitor now covers reboot and shutdown, which are the only actions besides logout that quattro still has.

What was checked at 7c292e04, on a disposable Omarchy worker with real systemd:

  • The bug, before and after. With systemctl reboot stubbed to list logind's inhibitors when the request arrives, quattro's command reboots with no lid inhibitor held. This branch reboots under a sleep:idle:handle-lid-switch block inhibitor ("Rebooting"), and the inhibitor is gone once the request returns. Shutdown is still inhibited ("Shutting down") and logout still is not.
  • Tests. system-power-test.sh passes 23 of 23 (30 before, less the seven reboot-boot-menu cases) and fails when run with quattro's bin/omarchy-system. hyprland-window-close-all-test.sh passes 4 of 4, and ./test/cli passes all 125 checks. CI is green.

Second opinion: Codex Medium reviewed the merge without running anything and found no defects. It agreed that the resolution loses nothing from either side, that none of the edited loops now passes without testing anything, and that the change is still correct and proportionate on current quattro. Its independence from this review is not guaranteed.

No open issue or competing pull request covers lid inhibition during reboot. This is labelled bug, verified and ready again, and is waiting on the maintainer.

@omarchybot omarchybot removed ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review labels Nov 16, 2026
quattro added the firmware action (omacom#19003) and the delayed exit OSD (omacom#19006). The lid inhibitor applies to every action but logout, so reboot to the BIOS is held against lid suspend too, and the firmware test's systemctl mock now requires the inhibitor for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Nov 17, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

This stopped merging after #19003 added a firmware action (reboot to the BIOS) to bin/omarchy-system and #19006 delayed its exit OSD, so I merged quattro into the branch as b0a11abd. bin/omarchy-system merged on its own and still differs from quattro only by this pull request's two lines. The one conflict was at the end of test/shell.d/system-power-test.sh, where both sides added a block: quattro's firmware test now comes first and the reboot block stays last, since it overwrites the shared worker file.

Because the inhibitor applies to every action except logout, reboot to the BIOS is now held against lid suspend as well. Closing the lid before that request is made could suspend the machine just as it can for a plain reboot, so this is the right behaviour, but it is new since the last review. The firmware test covers it: the systemctl mock now requires the inhibitor for every call, so that test fails if firmware runs uninhibited.

What was checked at b0a11abd, on a disposable Omarchy worker with real systemd, running the command through systemd-run --user as it really runs, with the power request and desktop calls stubbed:

  • The bug, before and after. quattro's command makes the reboot and firmware-reboot requests with no handle-lid-switch inhibitor held. This branch makes them under a sleep:idle:handle-lid-switch block inhibitor ("Rebooting", "Rebooting to BIOS"). Shutdown is still inhibited, now with the reason "Shutting down" instead of "Shutdown in progress", and logout still is not. No inhibitor is left behind once the command returns.
  • Tests. system-power-test.sh passes 24 of 24 (the earlier 23 plus quattro's firmware case) and fails when run with quattro's bin/omarchy-system. hyprland-window-close-all-test.sh passes 4 of 4, and ./test/cli passes all 136 checks. CI is green.

Second opinion: Codex Medium and muse-wonder (via pi, thinking high) reviewed the merge without running anything and found no defects. They agreed that the resolution loses nothing from either side, that the firmware test still tests something, and that holding the inhibitor through the delayed OSD's wait after the request cannot block the reboot itself, because it does not inhibit shutdown. Their independence from this review is not guaranteed.

No open issue or competing pull request covers lid inhibition during reboot. This is labelled bug, verified and ready again, and is waiting on the maintainer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working ready Good to merge verified Omarchy Triage has verified that this issue is ready for final review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants