Skip to content

Instantly share code, notes, and snippets.

@llagerlof
Last active December 15, 2022 01:19
Show Gist options
  • Save llagerlof/e4f6ddd1f54fec6d4966d5cc73c8f015 to your computer and use it in GitHub Desktop.
Save llagerlof/e4f6ddd1f54fec6d4966d5cc73c8f015 to your computer and use it in GitHub Desktop.
Script to check the CPU temperature and alert (gnome) if above threshold
#!/bin/bash
# It's supposed to run on a interval. Example to run each 5 seconds:
#
# watch -n 5 ./check_cpu_temperature.bash
cpu_temp=$(sensors | grep "CPU Temperature" | grep -Eo '[0-9]+' | head -n 1)
echo "$cpu_temp" >> ~/.cpu-temperature
if ((cpu_temp > 75)); then
temps=$(tac ~/.cpu-temperature | head -n 5 | xargs | sed -e 's/ /, /g')
notify-send "TEMPERATURE: $cpu_temp ($temps)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment