Files
lnx-arch/dots/bin/temperature.sh

37 lines
1.3 KiB
Bash
Raw Normal View History

2026-03-04 12:08:11 -05:00
#!/usr/bin/env bash
# 26.03.04 :: klevstul
# list all termal zones:
# `for i in /sys/class/thermal/thermal_zone*; do echo "$i: $(<$i/type)"; done`
# list all temperatures:
# `find /sys/devices -name "temp*_input"`
# pch_cometlake @ tuxwarrior (i found out by doing more on all tmp input files, and comparing with psensor values):
# `/sys/devices/virtual/thermal/thermal_zone3/hwmon6/temp1_input` = `/sys/class/hwmon/hwmon6/temp1_input`
2026-03-04 13:54:32 -05:00
threshold_1=$1
2026-03-04 13:55:45 -05:00
threshold_2=$2
temp_file=$3
2026-03-04 13:45:54 -05:00
2026-03-04 13:54:32 -05:00
threshold_1=${threshold_1:=59}
threshold_2=${threshold_2:=65}
2026-03-04 13:46:42 -05:00
temp_file=${temp_file:=/sys/devices/virtual/thermal/thermal_zone3/hwmon6/temp1_input}
2026-03-04 12:08:11 -05:00
# the value is reported in milli-degrees celsius. we divide by 1000 to convert to degrees celsius
2026-03-04 13:06:03 -05:00
# icon: https://fontawesome.com/icons/temperature-full?f=classic&s=solid
# to set colour in svg, set `fill="white"` in the file
2026-03-04 13:45:54 -05:00
temperature=$(($(cat ${temp_file}) / 1000))
2026-03-04 12:13:57 -05:00
2026-03-04 13:56:50 -05:00
if [[ ${temperature} -gt ${threshold_2} ]]; then
2026-03-04 13:54:32 -05:00
echo /home/poq/.config/nwg-panel/icons/temperature-full-solid-full.alarm2.svg
echo "WARNING: ${temperature}°C"
2026-03-04 13:56:50 -05:00
elif [[ ${temperature} -gt ${threshold_1} ]]; then
echo /home/poq/.config/nwg-panel/icons/temperature-full-solid-full.alarm1.svg
echo "${temperature}°C"
2026-03-04 13:06:03 -05:00
else
echo /home/poq/.config/nwg-panel/icons/temperature-full-solid-full.svg
2026-03-04 13:54:32 -05:00
echo "${temperature}°C"
2026-03-04 13:06:03 -05:00
fi
2026-03-04 12:13:57 -05:00