Created
January 2, 2026 17:11
-
-
Save KaiStarkk/d6a6cb2b1b45bf18ab626c5be2ac60d6 to your computer and use it in GitHub Desktop.
Sunshine disconnect watchdog - force-closes sessions on client disconnect
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Watches Sunshine log for disconnects and force-closes session via API | |
| # This triggers undo prep commands that would otherwise hang in "paused" state | |
| SUNSHINE_LOG="${XDG_CONFIG_HOME:-$HOME/.config}/sunshine/sunshine.log" | |
| SUNSHINE_API="https://localhost:47990/api" | |
| SUNSHINE_USER="${SUNSHINE_USER:-your-username}" | |
| SUNSHINE_PASS_FILE="${SUNSHINE_PASS_FILE:-$HOME/.config/sunshine_password}" | |
| [[ ! -f "$SUNSHINE_LOG" ]] && { echo "Waiting for sunshine.log..."; while [[ ! -f "$SUNSHINE_LOG" ]]; do sleep 5; done; } | |
| tail -n0 -F "$SUNSHINE_LOG" 2>/dev/null | while read -r line; do | |
| if [[ "$line" == *"CLIENT DISCONNECTED"* ]]; then | |
| curl -sk -X POST -H "Content-Type: application/json" \ | |
| -u "$SUNSHINE_USER:$(cat "$SUNSHINE_PASS_FILE")" \ | |
| "$SUNSHINE_API/apps/close" | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment