-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdwmblocks_sysstats
25 lines (17 loc) · 921 Bytes
/
dwmblocks_sysstats
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
#!/usr/bin/env bash
# CPU temp, RAM usage; a notification for CPU usage & GPU temp. Change awk/sed statements as needed depending on your hardware.
# Sensor info
cputemp=$(sensors | awk '/^Tdie/ {print substr($2,2,2)}')
memuse=$(free -m | awk '/^Mem/ {printf "%.1f\n", $3/1024}')
cpuuse=$(iostat -c | awk 'NR>=4 && NR <=4' | awk '{print "User CPU use: "$1"%\nSystem CPU use:",$3"%"}')
gputemp=$(sensors | awk '/^edge/ {print "\n\nGPU Temp: " $2}')
# Stats notification color
if [[ $cputemp -gt 75 ]]; then color="#bf616a"; elif [[ $cputemp -gt 65 ]]; then color="#ebcb8b"; else color="#a3be8c"; fi
# Sending to bar
echo $cputemp"°c" $memuse"g"
# Clicking on bar (requires statuscmd patch; https://dwm.suckless.org/patches/statuscmd/)
case $BLOCK_BUTTON in
1) setsid -w -f "$TERMINAL" -e htop ;;
3) notify-send -h string:bgcolor:$color "$cpuuse$gputemp" ;;
6) setsid -f "$TERMINAL" -e "$EDITOR" "$0" ;;
esac