aboutsummaryrefslogtreecommitdiff
path: root/pw-cputemp
diff options
context:
space:
mode:
authorPhilip Wittamore <philip@wittamore.com>2025-06-06 23:42:59 +0200
committerPhilip Wittamore <philip@wittamore.com>2025-06-06 23:42:59 +0200
commitc00b14c75468f7c91cb0e89de20d8433fba7c917 (patch)
treee2117c1037dd772734e81c956380f4023687799c /pw-cputemp
parent669b6b86a128f7559b257e69f07e610e26d0cd23 (diff)
downloadscripts-c00b14c75468f7c91cb0e89de20d8433fba7c917.tar.gz
scripts-c00b14c75468f7c91cb0e89de20d8433fba7c917.tar.bz2
scripts-c00b14c75468f7c91cb0e89de20d8433fba7c917.zip
update
Diffstat (limited to 'pw-cputemp')
-rwxr-xr-xpw-cputemp26
1 files changed, 26 insertions, 0 deletions
diff --git a/pw-cputemp b/pw-cputemp
new file mode 100755
index 0000000..eda3871
--- /dev/null
+++ b/pw-cputemp
@@ -0,0 +1,26 @@
+#!/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 ┊"
+