From 5fb19f10389b70ee2389755106092a9ef6c64598 Mon Sep 17 00:00:00 2001 From: David Moc Date: Sun, 24 May 2026 11:48:07 +0200 Subject: Go --- polybar/scripts/temp-status.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 polybar/scripts/temp-status.sh (limited to 'polybar/scripts/temp-status.sh') 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 -- cgit v1.2.3