#!/usr/bin/bash # ABOUTME: Waybar-Modul das die GPU-Auslastung als JSON ausgibt. # ABOUTME: Wird von der Waybar custom/gpu-usage Config referenziert. while : do GPU_STAT=$(cat /sys/class/hwmon/hwmon*/device/gpu_busy_percent 2>/dev/null | head -1 || echo "0") GPU_STAT="${GPU_STAT:-0}" ICON="" if [ "$GPU_STAT" -lt 10 ]; then ICON="" elif [ "$GPU_STAT" -lt 20 ]; then ICON="" elif [ "$GPU_STAT" -lt 40 ]; then ICON="" elif [ "$GPU_STAT" -lt 50 ]; then ICON="" elif [ "$GPU_STAT" -lt 60 ]; then ICON="" elif [ "$GPU_STAT" -lt 70 ]; then ICON="" elif [ "$GPU_STAT" -lt 80 ]; then ICON="" elif [ "$GPU_STAT" -lt 100 ]; then ICON="" fi s="text|alt|tooltip|class|percentage GPU $ICON|GPU $ICON $GPU_STAT%|GPU $ICON $GPU_STAT%|gpustat|$GPU_STAT" jq --unbuffered --compact-output -Rn ' ( input | split("|") ) as $keys | ( inputs | split("|") ) as $vals | [[$keys, $vals] | transpose[] | {key:.[0],value:.[1]}] | from_entries ' <<<"$s" sleep 5 done