#!/usr/bin/env bash
# hermes-display-chrome [--display N] [url...]
# Launch Google Chrome on a bot display with that display's own profile (CHROME_CONFIG_HOME) and
# accessibility forced on, so cua-driver's AT-SPI element mode sees the page.
set -euo pipefail
if [[ "${1:-}" == "--display" ]]; then
  N="$2"; shift 2
  ENVF="/run/hermes-display/$N/env"
  [[ -r "$ENVF" ]] || { echo "display :$N is not running ($ENVF missing)" >&2; exit 1; }
  set -a; . "$ENVF"; set +a
fi
: "${DISPLAY:?DISPLAY not set}"
: "${CHROME_CONFIG_HOME:?CHROME_CONFIG_HOME not set (use --display N)}"
exec /usr/bin/google-chrome-stable \
  --no-first-run --no-default-browser-check --password-store=basic --hide-crash-restore-bubble \
  --force-renderer-accessibility \
  --disable-features=Translate,MediaRouter \
  --window-position=64,40 --window-size=1152,688 \
  "$@"
