From a8d668a75538a8f3eb071de2f5570b97f25d0b77 Mon Sep 17 00:00:00 2001 From: borja Date: Tue, 25 Feb 2025 11:46:28 +0100 Subject: [PATCH] Adds Stats.app verifier --- check_stats.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 check_stats.sh diff --git a/check_stats.sh b/check_stats.sh new file mode 100755 index 0000000..35496b0 --- /dev/null +++ b/check_stats.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Define the processes to check +processes=( + "/Applications/Stats.app/Contents/MacOS/Stats" + "/Applications/Stats.app/Contents/PlugIns/WidgetsExtension.appex/Contents/MacOS/WidgetsExtension" +) + +# Function to check if a process is running +check_process() { + local process=$1 + pgrep -f "$process" >/dev/null +} + +# Check each process and restart Stats.app if necessary +for process in "${processes[@]}"; do + if ! check_process "$process"; then + echo "Restarting Stats.app..." + open "/Applications/Stats.app" + + # Wait for a short period to ensure the app starts (adjust as needed) + sleep 10 + + # Check again after waiting + if ! check_process "$process"; then + echo "Failed to restart Stats.app" | osascript -e 'tell application "Terminal" to do script "Failed to start Stats.app"' + fi + fi +done