Prevent lid closure from interrupting shutdown
This commit is contained in:
1 parent
28ceaae70e
commit
92f9864c72
2 files changed
+91
-34
No files matched your search
+18
-10
@@ -4,14 +4,22 @@
|
||||
# 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
|
||||
else
|
||||
# Schedule the shutdown in the user manager so closing the terminal's systemd
|
||||
# scope cannot terminate it before it runs.
|
||||
# Block lid handling explicitly: it ignores high-level sleep inhibitors.
|
||||
systemd-run --user --collect --quiet --property=Type=exec --property=RuntimeMaxSec=30s \
|
||||
systemd-inhibit --what=sleep:idle:handle-lid-switch \
|
||||
--who=Omarchy --why="Shutdown in progress" --mode=block \
|
||||
"$OMARCHY_PATH/bin/omarchy-system-shutdown" --inhibited
|
||||
fi
|
||||
Reference in new issue
Block a user