Files
omarchycn/migrations/1784970000.sh
T
David Heinemeier HanssonandClaude Opus 5 9ec7916c0b Keep the inhibit-delay check alive when there is nothing to check
Migrations run under bash -euo pipefail, where an assignment from a failed
command substitution ends the script. Reading InhibitDelayMaxSec out of a
drop-in that is not there exits sed 2, so the migration died at exactly the
condition it was written to detect: instead of flagging reboot-required, it
aborted before reaching the flag. The busctl read had the same shape, with
pipefail standing in for the failed substitution.

An aborted migration is never marked complete and takes omarchy-migrate's own
-e down with it, so the two migrations queued behind this one stopped running
as well.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-26 14:37:22 -07:00

26 lines
1.3 KiB
Bash

echo "Give the pre-suspend lock a window it can actually finish in"
# logind's five second default expires while Quickshell is still securing the
# session on lid close, and it suspends regardless. The shipped drop-in raises
# InhibitDelayMaxSec, but logind only reads it on reload.
#
# Reload rather than restart: restarting systemd-logind tears down the session.
sudo systemctl reload systemd-logind >/dev/null 2>&1 || true
# Check the property logind actually enforces, not the reload's exit status: a
# reload that returns success while the drop-in is missing or unparsed leaves
# the old five second window in place. omarchy-system-sleep-lock reads this same
# property at runtime, so it stays correct either way -- the reboot flag is only
# about getting the wider window to take effect.
#
# Both reads have to survive failing: a missing drop-in or an unreachable logind
# is the very condition being tested for, and migrations run under -e.
dropin=/etc/systemd/logind.conf.d/20-inhibit-delay.conf
expected_s=$(sed -n 's/^InhibitDelayMaxSec=//p' "$dropin" 2>/dev/null || true)
effective_us=$(busctl get-property org.freedesktop.login1 /org/freedesktop/login1 \
org.freedesktop.login1.Manager InhibitDelayMaxUSec 2>/dev/null | awk '{print $2}' || true)
if [[ -z $expected_s || $effective_us != $((expected_s * 1000000)) ]]; then
omarchy-state set reboot-required
fi