45 lines
1.6 KiB
Bash
Executable file
45 lines
1.6 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Live-monitor Idle Spectator focus / power-bar health from Player.log.
|
|
# Usage: ./scripts/monitor-spectator.sh
|
|
# Restart WorldBox after enabling debug_state_probe, press I, leave it running.
|
|
set -euo pipefail
|
|
|
|
LOG="${PLAYER_LOG:-$HOME/.config/unity3d/mkarpenko/WorldBox/Player.log}"
|
|
|
|
if [[ ! -f "$LOG" ]]; then
|
|
echo "Waiting for Player.log at $LOG"
|
|
while [[ ! -f "$LOG" ]]; do sleep 1; done
|
|
fi
|
|
|
|
echo "Monitoring $LOG"
|
|
echo "Looking for [IdleSpectator][STATE] / [IdleSpectator][BAD]"
|
|
echo "Healthy: idle=True focus=True powerBar=False while spectating"
|
|
echo "Bad: [BAD] lines, or powerBar=True while idle=True"
|
|
echo
|
|
|
|
bad_count=0
|
|
state_count=0
|
|
|
|
# Follow new lines; also print recent matching history once.
|
|
rg -n "\[IdleSpectator\]\[(STATE|BAD)\]|Spectator mode (enabled|disabled)|Watching \[" "$LOG" | tail -30 || true
|
|
echo "---- live ----"
|
|
|
|
tail -n 0 -F "$LOG" | while IFS= read -r line; do
|
|
if [[ "$line" == *"[IdleSpectator][BAD]"* ]]; then
|
|
bad_count=$((bad_count + 1))
|
|
printf '\033[1;31m%s\033[0m\n' "$line"
|
|
printf '\033[1;31m ^^ BAD #%s\033[0m\n' "$bad_count"
|
|
elif [[ "$line" == *"[IdleSpectator][STATE]"* ]]; then
|
|
state_count=$((state_count + 1))
|
|
if [[ "$line" == *"idle=True"* && "$line" == *"powerBar=True"* ]]; then
|
|
printf '\033[1;31m%s\033[0m\n' "$line"
|
|
printf '\033[1;31m ^^ power bar visible while idle\033[0m\n'
|
|
elif [[ "$line" == *"idle=True"* && "$line" == *"focus=False"* ]]; then
|
|
printf '\033[1;33m%s\033[0m\n' "$line"
|
|
else
|
|
printf '\033[1;32m%s\033[0m\n' "$line"
|
|
fi
|
|
elif [[ "$line" == *"[IdleSpectator]"* ]]; then
|
|
echo "$line"
|
|
fi
|
|
done
|