#!/bin/bash set -euo pipefail APP="Air Control" URL="https://github.com/FaysArukattil/air-control/releases/latest/download/Air-Control-mac-arm64.dmg" TMP="$(mktemp -d)" MNT="" cleanup() { [ -n "$MNT" ] && hdiutil detach "$MNT" -quiet 2>/dev/null || true; rm -rf "$TMP"; } trap cleanup EXIT if [ "$(uname -m)" != "arm64" ]; then echo "Sorry: this build needs an Apple Silicon Mac (M1 or newer)."; exit 1 fi echo "[1/4] Downloading $APP..." curl -fL -4 --http1.1 --connect-timeout 15 --speed-limit 10240 --speed-time 20 --retry 3 --retry-delay 2 "$URL" -o "$TMP/app.dmg" echo "[2/4] Mounting disk image..." MNT="$(hdiutil attach "$TMP/app.dmg" -nobrowse -readonly 2>/dev/null | grep -o '/Volumes/.*' | tail -1)" [ -d "$MNT/$APP.app" ] || { echo "Install failed: app not found in the download."; exit 1; } echo "[3/4] Copying $APP to /Applications..." osascript -e "quit app \"$APP\"" 2>/dev/null || true rm -rf "/Applications/$APP.app" cp -R "$MNT/$APP.app" /Applications/ xattr -cr "/Applications/$APP.app" echo "[4/4] Done! Opening $APP..." open "/Applications/$APP.app" echo "Next: allow Camera and Accessibility in System Settings > Privacy & Security (if upgrading, remove old Air Control with - and re-add with +), then restart the app."