diff --git a/scripts/gpu_power.sh b/scripts/gpu_power.sh index 33f1a742..efba040c 100755 --- a/scripts/gpu_power.sh +++ b/scripts/gpu_power.sh @@ -51,10 +51,18 @@ get_gpu() elif [[ "$gpu" == apple ]]; then usage="$(sudo powermetrics --samplers gpu_power -i500 -n 1 | grep 'GPU Power' | sed 's/GPU Power: \(.*\) \(.*\)/\1\2/g')" - else - usage='unknown' + elif [[ "$gpu" == Advanced ]]; then + usage=$( + for card in /sys/class/drm/card? + do + echo "$(($(cat "$card"/device/hwmon/hwmon?/power1_average) / 1000 / 1000))/$(($(cat "$card"/device/hwmon/hwmon?/power1_cap_max) / 1000 / 1000))W" + done | \ + sed -z -e 's/\n/|/g' -e 's/|$//g' + ) + else # "Intel" "Matrox", etc + usage="unknown" fi - normalize_percent_len $usage + echo $usage } main() diff --git a/scripts/gpu_ram_info.sh b/scripts/gpu_ram_info.sh index a3fceefa..f2bfc735 100755 --- a/scripts/gpu_ram_info.sh +++ b/scripts/gpu_ram_info.sh @@ -51,8 +51,17 @@ get_gpu() total_accuracy=$(get_tmux_option "@dracula-gpu-vram-total-accuracy" "d") usage=$(nvidia-smi --query-gpu=memory.used,memory.total --format=csv,noheader,nounits | awk "{ used += \$0; total +=\$2 } END { printf(\"%${used_accuracy}GB/%${total_accuracy}GB\n\", used / 1024, total / 1024) }") fi - else - usage='unknown' + elif [[ "$gpu" == Advanced ]]; then + usage="$( + for card in /sys/class/drm/card? + do + use=$(cat "$card"/device/mem_info_vram_used | numfmt --to=iec --suffix=B) + max=$(cat "$card"/device/mem_info_vram_total | numfmt --to=iec --suffix=B) + echo "$use/$max" + done | sed -z -e 's/\n/|/g' -e 's/|$//g' + )" + else # "Intel" "Matrox", etc + usage="unknown" fi echo $usage } diff --git a/scripts/gpu_usage.sh b/scripts/gpu_usage.sh index 70794aab..6477f211 100755 --- a/scripts/gpu_usage.sh +++ b/scripts/gpu_usage.sh @@ -46,8 +46,10 @@ get_gpu() usage=$(nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits | awk '{ sum += $0 } END { printf("%d%%\n", sum / NR) }') elif [[ "$gpu" == apple ]]; then usage="$(sudo powermetrics --samplers gpu_power -i500 -n 1 | grep 'active residency' | sed 's/[^0-9.%]//g' | sed 's/[%].*$//g')%" - else - usage='unknown' + elif [[ "$gpu" == Advanced ]]; then + usage="$(cat /sys/class/drm/card?/device/gpu_busy_percent | sed -z -e 's/\n/%|/g' -e 's/|$//g')" + else # "Intel" "Matrox", etc + usage="unknown" fi normalize_percent_len $usage }