You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
880 B
Bash
34 lines
880 B
Bash
#!/bin/bash
|
|
|
|
# Define the processes to check
|
|
# processes=(
|
|
# "/Applications/Stats.app/Contents/MacOS/Stats"
|
|
# "/Applications/Stats.app/Contents/PlugIns/WidgetsExtension.appex/Contents/MacOS/WidgetsExtension"
|
|
# )
|
|
|
|
processes=(
|
|
"/Applications/Stats.app/Contents/MacOS/Stats"
|
|
)
|
|
|
|
# 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
|