Opens a larger view. Escape closes it.

home-server

sunshine-game.sh

#!/bin/bash
APPID=$1

echo "Launching game AppID: $APPID"
steam steam://rungameid/$APPID &

# Wait for ANY Steam game activity (shader compilation OR game itself)
echo "Waiting for Steam to start game process..."
for i in $(seq 1 60); do
  pgrep -af "reaper.*AppId=$APPID" > /dev/null 2>&1 && break
  sleep 1
done

echo "Steam activity detected, monitoring..."

# Monitor - only exit if process stays gone for 90s
# Shader compilation can end, then there is a gap before the game actually launches.
# 30 checks x 3s = 90 seconds of patience for that gap.
MISSING_COUNT=0
MAX_MISSING=30

while true; do
  if pgrep -af "reaper.*AppId=$APPID" > /dev/null 2>&1; then
    if [ "$MISSING_COUNT" -gt 0 ]; then
      echo "Game process back (was missing for $((MISSING_COUNT * 3))s)"
    fi
    MISSING_COUNT=0
  else
    MISSING_COUNT=$((MISSING_COUNT + 1))
    echo "No game process, check $MISSING_COUNT/$MAX_MISSING ($(( MISSING_COUNT * 3 ))s / $((MAX_MISSING * 3))s)..."
    if [ "$MISSING_COUNT" -ge "$MAX_MISSING" ]; then
      echo "Game truly exited after $((MAX_MISSING * 3))s wait, ending session"
      break
    fi
  fi
  sleep 3
done