#!/bin/bash
exec > /tmp/amdwork/relaunch_chrome.out 2>&1
export DISPLAY=:99
# Kill ONLY the agent-profile chrome (never the main one)
pkill -f 'user-data-dir=/home/claude/chrome-profile-agent'
sleep 3
echo "killed agent chrome (if any)"
nohup /usr/bin/google-chrome \
  --user-data-dir=/home/claude/chrome-profile-agent \
  --remote-debugging-port=9223 \
  --remote-debugging-address=127.0.0.1 \
  --remote-allow-origins=* \
  --no-first-run \
  --no-default-browser-check \
  --disable-gpu-compositing \
  --ozone-platform=x11 \
  --window-position=0,0 \
  --window-size=1440,900 \
  --lang=en-US \
  about:blank \
  > /tmp/amdwork/chrome-agent.log 2>&1 &
echo "launched pid=$!"
sleep 6
curl -s http://localhost:9223/json/version || echo "9223 NOT UP"
echo ""
echo "=== DONE RELAUNCH ==="
