From 95a142be5215939fc6b5be643e4fa44650415e2c Mon Sep 17 00:00:00 2001 From: Philip Wittamore Date: Mon, 2 Jun 2025 20:53:45 +0200 Subject: update --- sb-systemstats | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 sb-systemstats (limited to 'sb-systemstats') diff --git a/sb-systemstats b/sb-systemstats new file mode 100755 index 0000000..0f69661 --- /dev/null +++ b/sb-systemstats @@ -0,0 +1,45 @@ +#!/usr/bin/env bash + +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" + + +# Try different fan sensors +FAN_SPEED=$(sensors | awk '/^fan|^cpu_fan/ {print $2}') +[ -z "$FAN_SPEED" ] && FAN_SPEED="N/A" + + +# Show warning icon if CPU temp is high +case $CPU_TEMP in + "N/A") COLOR="#d8dee9" && CPU_ICON="󰍛 ?" ;; + [7-9][6-9]|[8-9][0-9]|100) COLOR="#bf616a" && CPU_ICON="" ;; # Greater than 75 + [6][6-9]|7[0-5]) COLOR="#ebcb8b" && CPU_ICON="󰍛" ;; # Between 66 and 75 + *) COLOR="#a3be8c" && CPU_ICON="󰍛" ;; # 65 or below +esac + +# Send to bar +echo " 󰈐 $FAN_SPEED   $CPU_TEMP°C" + +# Clicking on bar +case $BLOCK_BUTTON in + 1) notify-send "$(sensors)";; + 2) notify-send "button 2 clicked";; + 3) notify-send "button 3 clicked";; +esac -- cgit v1.2.3