#!/bin/bash # One-command Flow rinse launcher (macOS). Not headless — Brave must be logged in — # but fully unattended once the tab is open and Auto-start is ticked in the popup. # # ./launch.sh https://labs.google/fx/tools/flow/project/XXXXXXXX # FLOW_URL=... ./launch.sh # # Does three things: start the queue server if it's down, keep the Mac awake, and # open OR focus a single Flow tab in Brave (never spawns duplicates). # # Scheduled every 10 min via launchd for self-healing (see install.sh). # NOTE: launchd can't execute scripts inside ~/Documents (macOS TCC blocks it), # so the agent runs a COPY at "~/Library/Application Support/flowrinse/" — # after editing this file or local_server_example.py, re-run ./install.sh to resync. set -e DIR="$(cd "$(dirname "$0")" && pwd)" URL="${1:-$FLOW_URL}" if [ -z "$URL" ]; then echo "Usage: ./launch.sh (or set FLOW_URL)" exit 1 fi # 1. queue server on 8017 (nc check avoids consuming a task via /next-task) if ! nc -z localhost 8017 2>/dev/null; then ( cd "$DIR" && caffeinate -s python3 -B local_server_example.py >/tmp/flowrinse.log 2>&1 & ) echo "started queue server + caffeinate (log: /tmp/flowrinse.log)" sleep 1 else echo "queue server already up on 8017" fi # 2. open or focus ONE Flow tab (reuses an existing one so it can't double-run). # Only `activate` (steal system focus) when opening fresh — on the 10-min launchd # tick an existing tab is re-selected inside Brave without yanking you out of # whatever you're doing. Selecting the tab also keeps Memory Saver from discarding it. osascript <