aboutsummaryrefslogtreecommitdiff
path: root/.config/polybar/scripts
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2024-03-13 22:13:20 +0200
committersrdusr <trevorgray@srdusr.com>2024-03-13 22:13:20 +0200
commit00db11a8386e786389c0e2d43cfaadc54007c9bb (patch)
treedb98b8ad7fb963df71878630d90c6c9a6d9b6aa0 /.config/polybar/scripts
parent5c6da18f95da36efe13633f20af9994f6deab71d (diff)
downloaddotfiles-00db11a8386e786389c0e2d43cfaadc54007c9bb.tar.gz
dotfiles-00db11a8386e786389c0e2d43cfaadc54007c9bb.zip
Remove one decimal point from output
Diffstat (limited to '.config/polybar/scripts')
-rwxr-xr-x.config/polybar/scripts/temperature.sh18
1 files changed, 12 insertions, 6 deletions
diff --git a/.config/polybar/scripts/temperature.sh b/.config/polybar/scripts/temperature.sh
index 10c8ddc..7ef6abb 100755
--- a/.config/polybar/scripts/temperature.sh
+++ b/.config/polybar/scripts/temperature.sh
@@ -2,11 +2,17 @@
# Pulls CPU temps, averages them, and outputs them
-let count=0
+count=0
sum=0.0
-for temp in $(sensors | grep "^Core" | grep -e '+.*C' | cut -f 2 -d '+' | cut -f 1 -d ' ' | sed 's/°C//'); do
- sum=$(echo $sum+$temp | bc)
- let count+=1
+
+# Iterate over each temperature reading
+for temp in "$(sensors | grep "^Core" | grep -e '+.*C' | cut -f 2 -d '+' | cut -f 1 -d ' ' | sed 's/°C//')"; do
+ sum=$(echo "$sum + $temp" | bc)
+ ((count++))
done
-avg=$(qalc -t $sum/$count)
-echo "${avg}°C"
+
+# Calculate the average
+avg=$(echo "scale=0; $sum / $count" | bc)
+
+# Output the average temperature without decimal points
+echo " ${avg%.*}°C"