Files
i3wm-ubuntu-dotfiles/.config/polybar/scripts/cpu_temp.sh
T
2026-01-29 23:19:44 +05:30

27 lines
482 B
Bash
Executable File

#!/usr/bin/env bash
# Get first CPU core temperature
TEMP=$(sensors | awk '/Core 0/ {print $3}' | tr -d '+°C')
# If temperature cannot be read
if [ -z "$TEMP" ]; then
echo "🌡 N/A"
exit 0
fi
# Convert to integer (truncate decimal)
TEMP_INT=${TEMP%.*}
# Color-coded emojis for cyberpunk style
if [ "$TEMP_INT" -lt 50 ]; then
EMOJI="🟢"
elif [ "$TEMP_INT" -lt 70 ]; then
EMOJI="🟡"
else
EMOJI="🔴"
fi
# Output with some flair
echo "$EMOJI $TEMP°C"