#!/bin/bash
MAX_TEMP=70
CHECK_INTERVAL=0.3
THERMAL_ZONE="/sys/class/thermal/thermal_zone3/temp"
COOLDOWN_TEMP=$((MAX_TEMP - 20)) # 50°C in this case
[ ! -f "$THERMAL_ZONE" ] && pino -t "Error" -m "Thermal zone not found!" -d 10 && exit 1
while true; do
temp=<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">(</mo><mo stretchy="false">(</mo></mrow></math>(cat "$THERMAL_ZONE") / 1000))
if [ "<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>t</mi><mi>e</mi><mi>m</mi><mi>p</mi><mi>"</mi><mo>−</mo><mi>g</mi><mi>t</mi><mi>"</mi></mrow></math>MAX_TEMP" ]; then
pino -t "CPU Overheating Warning" -m "Current temperature: ${temp}°C" -d 5
while [ "<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mi>t</mi><mi>e</mi><mi>m</mi><mi>p</mi><mi>"</mi><mo>−</mo><mi>g</mi><mi>t</mi><mi>"</mi></mrow></math>COOLDOWN_TEMP" ]; do
sleep "$CHECK_INTERVAL"
temp=<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow><mo stretchy="false">(</mo><mo stretchy="false">(</mo></mrow></math>(cat "$THERMAL_ZONE") / 1000))
done
fi
sleep "$CHECK_INTERVAL"
done