diff --git a/launch.sh b/launch.sh index 24c24c2..0ef06b7 100755 --- a/launch.sh +++ b/launch.sh @@ -37,24 +37,40 @@ fi # # Must name the browser the EXTENSION is loaded into. ultra = Brave, m3ultra = Chrome. BROWSER="${FLOW_BROWSER:-Brave Browser}" + +# A LOCKED SCREEN wedges every AppleScript window/tab query for ~2 min, then -1712 +# "AppleEvent timed out". Not a browser bug: with the screen locked, Finder, System Events +# and Brave all hang on `count of windows` identically. Bail out loudly instead. +if ioreg -n Root -d1 -r | tr -d ' ' | grep -q '"CGSSessionScreenIsLocked"=Yes'; then + echo "screen is LOCKED on $(hostname -s) — cannot drive $BROWSER (every window query would" \ + "hang, then -1712). Unlock it; for an unattended rig also set System Settings >" \ + "Lock Screen > 'Require password after screen saver begins' = Never." + exit 0 # not an error: the 10-min tick retries once someone unlocks +fi + +# `open location` hands the URL to the DEFAULT browser (Brave here) — never to $BROWSER. +# Make the tab inside the target app instead. Timeout so a wedged app can't hold the job. osascript <