summaryrefslogtreecommitdiff
path: root/polybar/scripts/temp-status.sh
diff options
context:
space:
mode:
authorDavid Moc <personal@cdatgoose.org>2026-05-24 11:48:07 +0200
committerDavid Moc <personal@cdatgoose.org>2026-05-24 11:48:07 +0200
commit5fb19f10389b70ee2389755106092a9ef6c64598 (patch)
tree969eb0466de581cb14aa09f751a95138620fc720 /polybar/scripts/temp-status.sh
Go
Diffstat (limited to 'polybar/scripts/temp-status.sh')
-rwxr-xr-xpolybar/scripts/temp-status.sh36
1 files changed, 36 insertions, 0 deletions
diff --git a/polybar/scripts/temp-status.sh b/polybar/scripts/temp-status.sh
new file mode 100755
index 0000000..d1f7665
--- /dev/null
+++ b/polybar/scripts/temp-status.sh
@@ -0,0 +1,36 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+temp=""
+
+if command -v sensors >/dev/null 2>&1; then
+ temp="$(
+ sensors 2>/dev/null |
+ awk '
+ /Package id 0:/ { gsub(/[^0-9.-]/, "", $4); print int($4); exit }
+ /Tctl:/ { gsub(/[^0-9.-]/, "", $2); print int($2); exit }
+ /temp1:/ && $2 ~ /^\+/ { gsub(/[^0-9.-]/, "", $2); print int($2); exit }
+ '
+ )"
+fi
+
+if [ -z "$temp" ]; then
+ for zone in /sys/class/thermal/thermal_zone*/temp; do
+ [ -r "$zone" ] || continue
+ value="$(cat "$zone")"
+ if [ "$value" -gt 0 ] 2>/dev/null; then
+ temp=$((value / 1000))
+ break
+ fi
+ done
+fi
+
+if [ -z "$temp" ]; then
+ echo "n/a"
+elif [ "$temp" -ge 80 ]; then
+ echo "%{F#cc241d}${temp}C%{F-}"
+elif [ "$temp" -ge 65 ]; then
+ echo "%{F#d79921}${temp}C%{F-}"
+else
+ echo "${temp}C"
+fi