26 lines
990 B
Bash
Executable File
26 lines
990 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Shut down after closing application windows
|
|
# omarchy:examples=omarchy shutdown | omarchy system shutdown
|
|
# omarchy:aliases=omarchy shutdown
|
|
|
|
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
|
|
) &
|
|
|
|
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
|