summaryrefslogtreecommitdiff
path: root/sb-gpu
blob: dfd24d7bbcbd77e578ca61bb1abb28db9d3d2455 (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
#!/bin/sh
lspci -k | grep -q "VGA compatible controller: NVIDIA" && NVIDIACard=1
getGPUClock() {
	sed -n "s/[0-9]: //g;/*/ {s/\s.*//; p}" /sys/class/drm/card1/device/pp_dpm_sclk
}
getGPUBusy() {
	cat /sys/class/drm/card1/device/gpu_busy_percent
}
getGPUTemperature() {
	sed "s/000//" /sys/class/drm/card1/device/hwmon/hwmon1/temp1_input
}
getGPUVRAM() {
	usedRAM=$(cat /sys/class/drm/card1/device/mem_info_vram_used)
	numfmt --to=iec $usedRAM --format %2.2f
}
getNVIDIA() {
	nvidia-smi | sed '10!d;s/ //g;s/^.*\([0-9][0-9]C\)/\1/;s/P[0-9]/ /;s/|/ /g;s/D.*$//'
}

case $BLOCK_BUTTON in
	#1) notify-send "RadeonTop" "$(radeontop)" ;;
	2) setsid -f "$TERMINAL" -e radeontop ;;
	3) notify-send "GPU Module" "\- Shows graphics core utilization.
- Middle Click to show RadeonTop." ;;
	6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac

if [ "$NVIDIACard" ]
then
printf "%s\n" "$(getNVIDIA)"
else
printf "%s %s %s%% 🌡️%s°\n" "$(getGPUClock)" "$(getGPUVRAM)" "$(getGPUBusy)" "$(getGPUTemperature)"
fi