#!/usr/bin/env bash # requires joypixels font in dwm config.def.h CPU_TEMP=$(sensors | awk ' /^Tdie|^Package id|^Core 0|^CPU|^temp1/ { gsub(/[+°C]/, ""); for (i=1; i<=NF; i++) { if ($i ~ /^[0-9]+(\.[0-9]+)?$/) { gsub(/\..*/, "", $i); print $i; exit; } } }') # Debug CPU temperature detection, if not found, return N/A if [ -z "$CPU_TEMP" ]; then # Try simpler pattern as fallback CPU_TEMP=$(sensors | grep -E '^(Core 0|Package id 0|CPU)' | awk '{print $3}' | tr -d '+°C' | head -n1) fi [ -z "$CPU_TEMP" ] && CPU_TEMP="N/A" # Send to bar echo -e " $CPU_TEMP°C" exit 0