Last active
December 15, 2022 01:19
-
-
Save llagerlof/e4f6ddd1f54fec6d4966d5cc73c8f015 to your computer and use it in GitHub Desktop.
Script to check the CPU temperature and alert (gnome) if above threshold
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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