NeoJolt

SP Football Life 2027

Nov 7th, 2026 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.35 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3.  
  4. # ====== Configuration ======
  5. WINDOW="SP Football Life 2027"
  6. PROCESS="FL 2027 start.exe"
  7. TIMEOUT_APPEAR=90          # only for the initial window appearance
  8. # ===========================
  9.  
  10. # Flatpak → host helper
  11. if [[ -f /.flatpak-info ]]; then
  12.     HOST_CMD=(flatpak-spawn --host)
  13. else
  14.     HOST_CMD=()
  15. fi
  16.  
  17. # Prefer kdotool, fall back to xdotool
  18. if "${HOST_CMD[@]}" command -v kdotool >/dev/null 2>&1; then
  19.     TOOL_CMD=("${HOST_CMD[@]}" kdotool)
  20. elif "${HOST_CMD[@]}" command -v xdotool >/dev/null 2>&1; then
  21.     TOOL_CMD=("${HOST_CMD[@]}" xdotool)
  22. else
  23.     echo "Error: neither kdotool nor xdotool found" >&2
  24.     exit 1
  25. fi
  26.  
  27. window_exists() {
  28.     [[ -n "$("${TOOL_CMD[@]}" search --name "$WINDOW" 2>/dev/null || true)" ]]
  29. }
  30.  
  31. # Wait for the window to appear (with timeout so the script doesn't hang forever if the game fails to start)
  32. start=$SECONDS
  33. while ! window_exists; do
  34.     if (( SECONDS - start >= TIMEOUT_APPEAR )); then
  35.         echo "Timeout: window '$WINDOW' did not appear within ${TIMEOUT_APPEAR}s" >&2
  36.         exit 1
  37.     fi
  38.     sleep 0.15
  39. done
  40.  
  41. # Wait until the window disappears — no timeout, play as long as you want
  42. while window_exists; do
  43.     sleep 0.5
  44. done
  45.  
  46. # Game has closed → clean up the process if it's still lingering
  47. "${HOST_CMD[@]}" pkill -f "$PROCESS" 2>/dev/null || true
Advertisement
Add Comment
Please, Sign In to add comment