-
Notifications
You must be signed in to change notification settings - Fork 0
/
amdgpu
executable file
·102 lines (86 loc) · 2.85 KB
/
amdgpu
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/sh
# shellcheck disable=1090,2154
. "${XDG_CACHE_HOME-$HOME/.cache}/wal/colors.sh"
blockcolor=$color9
txtcolor=$color0
print_block() {
input=$1
printf "<b><span foreground='%s' background='%s'></span>" \
"$blockcolor" "$color0"
printf "<span foreground='%s' background='%s'> %s </span>" \
"$txtcolor" "$blockcolor" "$input"
printf "<span foreground='%s' background='%s'></span></b>\n" \
"$color0" "$blockcolor"
}
# GPUs aren't usually hot-swapped unless it's a thunderbolt eGPU system,
# so just check the GPU's identity once per boot
[ -f /tmp/i3bgpu ] || {
if command -v glxinfo >/dev/null; then
glxinfo -B | awk -F':' '/OpenGL renderer string/ {print $2}' | xargs |
tr ' ' '\n' | head -1 >/tmp/i3bgpu
else
lspci | awk -F':' '/VGA/ {print $3}' | xargs | tr ' ' '\n' | head -1 |
sed 's|Advanced|AMD|' >/tmp/i3bgpu
fi
}
case "$(cat /tmp/i3bgpu)" in
"AMD")
monitor_program="radeontop -c"
lm_sensors_name="amdgpu"
;;
"Intel") ;;
"NVIDIA") ;;
esac
gpu_info_dir=/sys/class/drm/card0/device
hwmon_dev=$(ls $gpu_info_dir/hwmon)
[ -n "$hwmon_dev" ] || {
echo >&2 "Error: Your GPU is not supported."
exit 1
}
shader_clock=$(($(cat "$gpu_info_dir/hwmon/$hwmon_dev/freq1_input") / 1000000))
case $BLOCK_BUTTON in
1) # Left Click
gpuinfo=$(sensors | grep $lm_sensors_name -A10)
notify-send \
-h string:x-canonical-private-synchronous:i3bamdgpu \
-i ~/.local/bin/i3blocks/img/gpu.png \
"Voltages/Temps/Fan RPM/Power Usage for my$(
glxinfo -B | awk -F':' '/OpenGL renderer string/{print $2}' | awk -F'(' '{print $1}'
)" "$(echo "$gpuinfo" | grep -A8 vddgfx)"
;;
2) # Middle Click
$TERMINAL --class float -e "$monitor_program"
;;
3) # Right Click
notify-send \
-h string:x-canonical-private-synchronous:i3bamdgpu \
-i ~/.local/bin/i3blocks/img/gpu.png \
"Clock/VRAM Stats for my$(
glxinfo -B | awk -F':' '/OpenGL renderer string/{print $2}' | awk -F'(' '{print $1}'
)" "Shader Usage: $(cat $gpu_info_dir/gpu_busy_percent)%
Memory Usage: $(cat $gpu_info_dir/mem_busy_percent)%
VRAM Usage: $(echo "$(cat $gpu_info_dir/mem_info_vram_used)"/1000000000 | bc -l | cut -c-3)/$(echo "$(cat $gpu_info_dir/mem_info_vram_total)"/1000000000 | bc -l | cut -c-3)Gi
Memory Clock: $(grep "\*" $gpu_info_dir/pp_dpm_mclk | awk '{print $2}')
Shader Clock: $shader_clock"
;;
4) # Scroll Up
;;
5) # Scroll Down
;;
esac
usage=$(cat $gpu_info_dir/gpu_busy_percent)
icon=""
# if [ "$usage" -ge 90 ] ; then
# usage_icon=""
# elif [ "$usage" -ge 60 ] ; then
# usage_icon=""
# elif [ "$usage" -ge 40 ] ; then
# usage_icon=""
# elif [ "$usage" -ge 10 ] ; then
# usage_icon=""
# else
# usage_icon=""
# fi
power_usage=$(($(cat "$gpu_info_dir/hwmon/$hwmon_dev/power1_average") / 1000000))
temp=$(($(cat "$gpu_info_dir/hwmon/$hwmon_dev/temp2_input") / 1000))
print_block "$icon ${usage}% ${shader_clock}MHz ${power_usage}W ${temp}°C"