blob: 76cec99843215947f0fc168f11a54dd3c668d365 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/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"
# Try different fan sensors
FAN_SPEED=$(sensors | awk '/^fan|^cpu_fan/ {print $2}')
[ -z "$FAN_SPEED" ] && FAN_SPEED="N/A"
# Send to bar
echo " 🌀 $FAN_SPEED ┊ 🌡️ $CPU_TEMP"
# Clicking on bar
case $BLOCK_BUTTON in
1) notify-send "$(sensors)";;
2) notify-send "button 2 clicked";;
3) notify-send "button 3 clicked";;
esac
|