~kris/dots

srice

2582f0c4173a4ad6a31e0cb759473c893cdc4e93 — Kris Yotam 2 months ago 9f828eb
sb-cpu: portable temp source (Intel Core 0, AMD Tdie/Tctl, Asahi NVMe Composite fallback)
1 files changed, 9 insertions(+), 1 deletions(-)

M .local/bin/statusbar/sb-cpu
M .local/bin/statusbar/sb-cpu => .local/bin/statusbar/sb-cpu +9 -1
@@ 9,4 9,12 @@ case $BLOCK_BUTTON in
	6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

sensors | awk '/Core 0/ {print "🌡" $3}'
# Temperature source, in order of preference:
#   Intel x86      -> "Core 0"   (field 3, e.g. +45.0°C)
#   AMD x86        -> "Tdie/Tctl" (field 2)
#   Apple Silicon  -> Asahi exposes no CPU die sensor; fall back to the
#                     NVMe "Composite" temp as a system-temperature proxy
temp=$(sensors 2>/dev/null | awk '/Core 0/ {print $3; exit}')
[ -z "$temp" ] && temp=$(sensors 2>/dev/null | awk '/Tdie|Tctl/ {print $2; exit}')
[ -z "$temp" ] && temp=$(sensors 2>/dev/null | awk '/Composite/ {print $2 $3; exit}')
[ -n "$temp" ] && printf '🌡%s\n' "$temp"