From fb97ace1667c5f6841a5978526f516b9e0f16b19 Mon Sep 17 00:00:00 2001 From: Luca Matei Pintilie Date: Sat, 10 Aug 2024 19:08:24 +0200 Subject: swayrbar: fix scripts --- .config/swayrbar/scripts/temp-status | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to '.config/swayrbar/scripts/temp-status') diff --git a/.config/swayrbar/scripts/temp-status b/.config/swayrbar/scripts/temp-status index 60220d2..2d54d39 100755 --- a/.config/swayrbar/scripts/temp-status +++ b/.config/swayrbar/scripts/temp-status @@ -1,6 +1,16 @@ #!/usr/bin/env sh -temps="$(cat /sys/class/hwmon/hwmon*/temp*_input)" -temp=$(echo \("$(echo -n "$temps" | tr '\n' '+')) / $(echo "$temps" | wc -l) / 1000" | bc) +total_temp=0 +i=0 -echo -n "$temp" °C +for temp_file in /sys/class/hwmon/hwmon*/temp*_input +do + temp="$(cat "${temp_file}")" + if [ "${temp}" != "0" ] + then + total_temp="$(( ${total_temp} + ${temp} ))" + i="$(( ${i} + 1 ))" + fi +done + +echo -n "$(( ${total_temp} / ${i} / 1000 ))" °C -- cgit v1.2.3