Merge pull request #13076 from chemineer1/codex/shutdown-lid-inhibit

Prevent lid closure from interrupting shutdown
This commit is contained in:
David Heinemeier Hansson authored and GitHub committed 2026-10-04 07:39:20 -04:00
commit 58aa85721d
2 files changed
+145 -34

No files matched your search

+25 -10
View File
@@ -4,14 +4,29 @@
# omarchy:examples=omarchy shutdown | omarchy system shutdown
# omarchy:aliases=omarchy shutdown
# Schedule the shutdown in the user manager so closing the terminal's systemd
# scope cannot terminate it before it runs.
systemd-run --user --collect --quiet --on-active="2s" --timer-property=AccuracySec=100ms systemctl poweroff --no-wall || exit 1
if [[ ${1:-} == "--inhibited" ]]; then
# Close windows in the background so they cannot delay power-off.
(
omarchy-osd -i shutdown -m "Shutting down" -d 5000
omarchy-state clear re*-required
omarchy-hyprland-window-close-all
) &
omarchy-osd -i shutdown -m "Shutting down" -d 5000
omarchy-state clear re*-required
# Now close all windows
omarchy-hyprland-window-close-all
sleep 1 # Allow apps like Chrome to shutdown correctly
sleep 2 # Allow apps like Chrome to shut down correctly
systemctl poweroff --no-wall
elif [[ ${1:-} == "--inhibit" ]]; then
# Report failures from inside the service, independently of the launching terminal.
# Block lid handling explicitly: it ignores high-level sleep inhibitors.
systemd-inhibit --what=sleep:idle:handle-lid-switch \
--who=Omarchy --why="Shutdown in progress" --mode=block \
"$0" --inhibited || {
status=$?
omarchy-notification-send -u critical "Shutdown failed" "Could not complete shutdown. Please try again."
exit "$status"
}
else
# Schedule the shutdown in the user manager so closing the terminal's systemd
# scope cannot terminate it before it runs.
systemd-run --user --collect --quiet --property=Type=exec --property=RuntimeMaxSec=30s \
"$OMARCHY_PATH/bin/omarchy-system-shutdown" --inhibit
fi