Files
lnx-arch/dots/bin/temperature.sh
committer@tuxwarrior cbfcce6faa u
2026-03-04 13:46:42 -05:00

31 lines
1.1 KiB
Bash
Executable File

#!/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`
threshold=$1
temp_file=$1
threshold=${threshold:=60}
temp_file=${temp_file:=/sys/devices/virtual/thermal/thermal_zone3/hwmon6/temp1_input}
# the value is reported in milli-degrees celsius. we divide by 1000 to convert to degrees celsius
# icon: https://fontawesome.com/icons/temperature-full?f=classic&s=solid
# to set colour in svg, set `fill="white"` in the file
temperature=$(($(cat ${temp_file}) / 1000))
if [[ ${temperature} -gt ${threshold} ]]; then
echo /home/poq/.config/nwg-panel/icons/temperature-full-solid-full.alarm.svg
else
echo /home/poq/.config/nwg-panel/icons/temperature-full-solid-full.svg
fi
echo "${temperature}°C"