#!/bin/bash if [ -f .env ]; then set -a source .env set +a fi FULL_URL=https://api.steampowered.com/ISteamUser/GetPlayerSummaries/v2 RESPONSE=$(curl -s "$FULL_URL/?key=$STEAM_KEY&steamids=$STEAM_USERID64") if ! echo "$RESPONSE" | jq empty 2>/dev/null; then echo "Error response from API: $RESPONSE" exit 1 fi APPID=$(echo $RESPONSE | jq -r '.response.players[0].gameid') if [ "$APPID" != "null" ] && [ -n "$APPID" ]; then if pgrep -fa "AppId=$STEAM_RUNGAMEID" > /dev/null && [ "$APPID" = "$STEAM_RUNGAMEID" ]; then echo "[automate steam] detected playing: $APPID on this device. skipping" elif pgrep -f steam > /dev/null; then # If not playing on CURRENT DEVICE but DETECTED PLAYING ON ACCOUNT echo "[automate steam] detected playing: $APPID ON OTHER DEVICE. quitting" steam steam://exit fi else echo "[automate steam] not playing anything on any device, running game..." steam -cef-disable-gpu steam://rungamid/$STEAM_RUNGAMEID fi