Skip to content

Instantly share code, notes, and snippets.

@nielsole
Last active June 27, 2024 09:27
Show Gist options
  • Save nielsole/7b5a217ae2bb8fa54626f58b736feb91 to your computer and use it in GitHub Desktop.
Save nielsole/7b5a217ae2bb8fa54626f58b736feb91 to your computer and use it in GitHub Desktop.
Thermalert continuously monitors temperature of a mac.
#!/bin/bash
while true; do
# Get the current CPU_Speed_Limit value
CPU_SPEED_LIMIT=$(pmset -g therm | grep "CPU_Speed_Limit" | awk '{print $3}')
# Check if CPU_Speed_Limit is less than 80
if (( CPU_SPEED_LIMIT < 80 )); then
# Send notification
osascript -e 'display notification "CPU Speed Limit is below 80%: '"$CPU_SPEED_LIMIT"'%" with title "CPU Speed Alert" sound name "Funk"'
else
echo "No thermal throttling detected: $CPU_SPEED_LIMIT"
fi
# Wait for a minute before checking again
sleep 60
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment