summaryrefslogtreecommitdiff
path: root/.local/bin/statusbar/sb-gpubar
blob: 5cbdf185270312fe70678594ee68b172e3bda5c5 (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
#!/bin/sh

# Module showing GPU load as a changing bar.

case $BLOCK_BUTTON in
2) setsid -f "$TERMINAL" -e gpuwatch ;;
3) notify-send "󰢮 GPU load module" "The bars represents
GPU utilization and memory allocation" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

memutil=$(nvidia-smi --query-gpu=utilization.gpu --format=csv | awk 'FNR == 2 {print $1}')
gpuutil=$(nvidia-smi --query-gpu=utilization.memory --format=csv | awk 'FNR == 2 {print $1}')
temp=$(nvidia-smi --query-gpu=temperature.gpu --format=csv | awk 'FNR == 2 {print $1}')
printf ""
for var in $memutil $gpuutil; do
	case "$var" in
	[0-9] | 1[0-9]) printf "▁" ;;
	2[0-9]) printf "▂" ;;
	3[0-9]) printf "▃" ;;
	4[0-9]) printf "▄" ;;
	5[0-9]) printf "▅" ;;
	6[0-9]) printf "▆" ;;
	7[0-9]) printf "▇" ;;
	8[0-9]) printf "█" ;;
	*) printf "█" ;;
	esac
done
printf " 󰔏$temp°C"
printf "\\n"