A monitor powered off when the machine boots — a smart strip cutting AC, the PC coming back on its own — still answers DDC, but with a partial EDID that carries no video modes. Hyprland takes the connector as present and brings the monitor up at 0x0. Powering it on afterwards changes nothing: the connector never dropped at DRM level, so no hotplug fires, nothing re-reads the EDID, and the screen stays black until a reboot. Only a reload re-reads it. Forcing a DRM re-probe would work too but needs root, and the kernel's cached mode list stays empty without one, so there is nothing cheaper to poll: the reload is both the fix and the only way to learn whether it was needed. Poll only while a monitor is in that state, back off from three seconds to a minute, and stop as soon as one reports a mode — the machine can sit black all night, and powering the monitor on fires no event to stop on. Nothing will ask again if this loop gives up, so an unreadable answer is not taken for a healthy monitor. It is also not waited on forever: a compositor that stays silent has gone, and with it the session and any reason to keep asking. Reloading on our own schedule means minding the reload guard, which exists to keep Hyprland out of package-owned config mid-transaction, and which only disables the automatic reloads. The guard can now be asked, and recovery holds off while a transaction is in flight. A reload lands a monitor at 0x0 the same way a boot does, so configreloaded is watched alongside the hotplug events. The recovery's own reload comes back through it, and a lock keeps that from stacking a second loop. Contention waits rather than drops: a trigger arriving while a loop is exiting is the last one that will come, and one arriving while a loop is running is answered by its next pass anyway. Mirrors are dropped from `hyprctl monitors`, so the check asks for all of them and filters the disabled ones itself. Monitors turned off on purpose sit at 0x0 too, and re-applying config would fight the user over those. The existing poll here recovers internal panels on docked laptops and never runs on a desktop, which is where this happens. Reported in #6668. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
87 lines
3.5 KiB
Bash
Executable File
87 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
source "$(dirname "$0")/base-test.sh"
|
|
|
|
test_tmp=$(mktemp -d)
|
|
trap 'rm -rf "$test_tmp"' EXIT
|
|
|
|
run_root="$test_tmp/run-user"
|
|
state_dir="$test_tmp/state"
|
|
hyprctl_log="$test_tmp/hyprctl.log"
|
|
fake_hyprctl="$test_tmp/hyprctl"
|
|
signature="test-signature"
|
|
runtime_dir="$run_root/1000"
|
|
|
|
dead_signature="dead-signature"
|
|
|
|
mkdir -p "$runtime_dir/hypr/$signature" "$runtime_dir/hypr/$dead_signature"
|
|
|
|
cat >"$fake_hyprctl" <<'BASH'
|
|
#!/bin/bash
|
|
|
|
printf '%s\t%s\n' "$XDG_RUNTIME_DIR" "$*" >>"$FAKE_HYPRCTL_LOG"
|
|
|
|
case "$*" in
|
|
*'--instance dead-signature '*)
|
|
printf "Couldn't connect to %s/hypr/dead-signature/.socket.sock. (4)\n" "$XDG_RUNTIME_DIR"
|
|
exit 4
|
|
;;
|
|
*'getoption misc.disable_autoreload'*)
|
|
printf '{"option":"misc.disable_autoreload","bool":%s,"set":true}\n' "${FAKE_DISABLE_AUTORELOAD:-false}"
|
|
;;
|
|
*'getoption debug.suppress_errors'*)
|
|
printf '{"option":"debug.suppress_errors","bool":%s,"set":true}\n' "${FAKE_SUPPRESS_ERRORS:-false}"
|
|
;;
|
|
*)
|
|
printf 'ok\n'
|
|
;;
|
|
esac
|
|
BASH
|
|
chmod 0755 "$fake_hyprctl"
|
|
|
|
FAKE_HYPRCTL_LOG="$hyprctl_log" \
|
|
HYPRCTL="$fake_hyprctl" \
|
|
OMARCHY_HYPRLAND_RELOAD_GUARD_RUN_ROOT="$run_root" \
|
|
OMARCHY_HYPRLAND_RELOAD_GUARD_STATE_DIR="$state_dir" \
|
|
"$ROOT/bin/omarchy-hyprland-reload-guard" pause 2>"$test_tmp/pause-stderr"
|
|
|
|
state_file="$state_dir/$signature"
|
|
[[ -f $state_file ]] || fail "reload guard stores Hyprland state on pause"
|
|
expected_state=$(printf '%s\tfalse\tfalse' "$runtime_dir")
|
|
grep -Fx "$expected_state" "$state_file" >/dev/null || fail "reload guard records previous Hyprland reload settings"
|
|
grep -F 'hl.config({ misc = { disable_autoreload = true }, debug = { suppress_errors = true } })' "$hyprctl_log" >/dev/null || fail "reload guard pauses autoreload with hyprctl eval"
|
|
pass "reload guard pauses live Hyprland reloads"
|
|
|
|
[[ ! -e $state_dir/$dead_signature ]] || fail "reload guard skips instances hyprctl cannot reach"
|
|
[[ ! -s $test_tmp/pause-stderr ]] || fail "reload guard pauses dead Hyprland instances quietly" "$(cat "$test_tmp/pause-stderr")"
|
|
pass "reload guard skips dead Hyprland instances quietly"
|
|
|
|
: >"$hyprctl_log"
|
|
FAKE_HYPRCTL_LOG="$hyprctl_log" \
|
|
HYPRCTL="$fake_hyprctl" \
|
|
OMARCHY_HYPRLAND_RELOAD_GUARD_RUN_ROOT="$run_root" \
|
|
OMARCHY_HYPRLAND_RELOAD_GUARD_STATE_DIR="$state_dir" \
|
|
"$ROOT/bin/omarchy-hyprland-reload-guard" resume
|
|
|
|
[[ ! -e $state_file ]] || fail "reload guard clears Hyprland state after resume"
|
|
grep -F -- '--instance test-signature reload' "$hyprctl_log" >/dev/null || fail "reload guard forces one Hyprland reload after package transaction"
|
|
grep -F 'hl.config({ misc = { disable_autoreload = false }, debug = { suppress_errors = false } })' "$hyprctl_log" >/dev/null || fail "reload guard restores previous Hyprland reload settings"
|
|
pass "reload guard resumes live Hyprland reloads"
|
|
|
|
# The modeless monitor recovery loop reloads on its own schedule, so it needs to
|
|
# ask whether a transaction is in flight.
|
|
rm -rf "$state_dir"
|
|
OMARCHY_HYPRLAND_RELOAD_GUARD_STATE_DIR="$state_dir" "$ROOT/bin/omarchy-hyprland-reload-guard" paused &&
|
|
fail "reload guard reports itself unpaused before any transaction"
|
|
|
|
mkdir -p "$state_dir"
|
|
OMARCHY_HYPRLAND_RELOAD_GUARD_STATE_DIR="$state_dir" "$ROOT/bin/omarchy-hyprland-reload-guard" paused &&
|
|
fail "an empty state directory is not a paused transaction"
|
|
|
|
touch "$state_dir/some-signature"
|
|
OMARCHY_HYPRLAND_RELOAD_GUARD_STATE_DIR="$state_dir" "$ROOT/bin/omarchy-hyprland-reload-guard" paused ||
|
|
fail "reload guard reports itself paused during a transaction"
|
|
pass "reload guard reports whether a transaction is holding reloads"
|