#!/bin/bash
APP=$1
OUTPUT=$2

mkdir -p book/images

echo "Taking screenshot of $APP on remote machine..."
ssh geo@192.168.1.136 "cd /home/geo/grimos && xvfb-run -a -s '-screen 0 1024x768x24' python3 automate.py --app '$APP' --output '/tmp/$OUTPUT'"

echo "Copying image back to local workspace..."
scp geo@192.168.1.136:/tmp/$OUTPUT book/images/$OUTPUT

echo "Cleaning up remote image..."
ssh geo@192.168.1.136 "rm /tmp/$OUTPUT"

echo "Done! Image saved to book/images/$OUTPUT"
