#!/bin/bash
set -eu
systemctl --user start kpa1500-web.service
for attempt in $(seq 1 30); do
  if /usr/bin/curl --silent --fail http://127.0.0.1:4525/host-api/status >/dev/null; then
    exec /usr/bin/chromium --user-data-dir=/home/tuckpi/.config/kpa1500-host-chromium --app=http://127.0.0.1:4525 --start-maximized --class=KPA1500HostSetup
  fi
  sleep 0.25
done
notify-send 'KPA1500 Web Remote' 'The host service did not start. Check systemctl --user status kpa1500-web.' 2>/dev/null || true
exit 1
