Harden Panama launcher actions

This commit is contained in:
Gabriel Brown
2026-08-18 07:31:11 -04:00
parent b28edcd01f
commit ca64d4b9b6
11 changed files with 239 additions and 40 deletions
@@ -9,6 +9,7 @@ fail() {
active_target=""
original_state=""
night_light_snapshot=""
restore_target() {
local target="$1" expected="$2" current
@@ -22,6 +23,12 @@ cleanup() {
if [[ -n $active_target ]]; then
restore_target "$active_target" "$original_state"
fi
if [[ -n $night_light_snapshot ]]; then
local enabled automatic
enabled="$(jq -r '.enabled' <<<"$night_light_snapshot")"
automatic="$(jq -r '.automatic' <<<"$night_light_snapshot")"
qs ipc call night-light restore "$enabled" "$automatic" >/dev/null 2>&1 || true
fi
}
trap cleanup EXIT
@@ -51,6 +58,22 @@ rg -q '^target caffeine$' <<<"$ipc" || fail 'caffeine IPC target is missing'
rg -q '^target night-light$' <<<"$ipc" || fail 'night-light IPC target is missing'
exercise_toggle caffeine
night_light_snapshot="$(qs ipc call night-light settings)"
jq -e '.enabled | type == "boolean"' <<<"$night_light_snapshot" >/dev/null \
|| fail 'night-light settings omitted enabled state'
jq -e '.automatic | type == "boolean"' <<<"$night_light_snapshot" >/dev/null \
|| fail 'night-light settings omitted automatic state'
exercise_toggle night-light
original_enabled="$(jq -r '.enabled' <<<"$night_light_snapshot")"
original_automatic="$(jq -r '.automatic' <<<"$night_light_snapshot")"
qs ipc call night-light restore "$original_enabled" "$original_automatic" >/dev/null
restored_snapshot="$(qs ipc call night-light settings)"
[[ "$(jq -r '.enabled' <<<"$restored_snapshot")" == "$original_enabled" ]] \
|| fail 'night-light enabled state was not restored'
[[ "$(jq -r '.automatic' <<<"$restored_snapshot")" == "$original_automatic" ]] \
|| fail 'night-light automatic schedule was not restored'
night_light_snapshot=""
printf 'Panama action IPC contract: PASS\n'