From d87138ae6c34ddd2dce2ee2c3703a4afcf2c27f3 Mon Sep 17 00:00:00 2001 From: Siraaj Khandkar Date: Wed, 3 Mar 2021 08:47:37 -0500 Subject: [PATCH] Handle more thermal sensors --- home/lib/login_functions.sh | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/home/lib/login_functions.sh b/home/lib/login_functions.sh index 01e0ffa..1f69061 100644 --- a/home/lib/login_functions.sh +++ b/home/lib/login_functions.sh @@ -556,14 +556,29 @@ status() { echo + local _dir temp_input label_file label + printf '%sthermal\n' "$indent_unit" - for _dir in /sys/class/thermal/thermal_zone* - do - printf '%s %.2f C\n' \ - $(cat "$_dir"/type) \ - $(( $(cat "$_dir"/temp) / 1000 )) + for _dir in /sys/class/hwmon/hwmon*; do + cat "$_dir"/name + find "$_dir"/ -name 'temp*_input' \ + | while read -r temp_input; do + label_file=${temp_input//_input/_label} + if [ -f "$label_file" ]; then + label=$(< "$label_file") + else + label='' + fi + awk -v label="$label" '{ + if (label) + label = sprintf(" (%s)", label) + printf("%.2f°C%s\n", $1 / 1000, label) + }' \ + "$temp_input" + done \ + | sort \ + | indent "$indent_unit" done \ - | column -t \ | indent "${indent_unit}${indent_unit}" echo 'net' -- 2.20.1