Files
dashboard/widgets/gpu-widget.sh
Francisco 7b2949e739 Initial commit: conky dashboard + DogeBot
Three conky panels (main, dayz, doge) plus all widgets, NUT config templates,
and the systemd timer that drives the qwen2.5:1.5b vibe report on maeth-storage.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-12 01:16:54 -04:00

36 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
header() {
printf '${color 34D399}▎${color} ${color F1F5F9}${font Inter:bold:size=9}LOCAL GPU${font}${color}${alignr}${color %s}●${color}\n' "$1"
}
if ! command -v nvidia-smi >/dev/null 2>&1; then
header FB7185
echo '${color FB7185}nvidia-smi missing${color}'
exit 0
fi
query='index,name,utilization.gpu,memory.used,memory.total,temperature.gpu,power.draw,power.limit'
if ! output="$(nvidia-smi --query-gpu="$query" --format=csv,noheader,nounits 2>/dev/null)"; then
header FB7185
echo '${color FB7185}nvidia unavailable${color}'
exit 0
fi
header 34D399
while IFS=',' read -r index name util mem_used mem_total temp power limit; do
index="$(printf '%s' "$index" | xargs)"
name="$(printf '%s' "$name" | sed -E 's/^NVIDIA GeForce //; s/^GeForce //; s/^NVIDIA //; s/ +/ /g' | xargs)"
util="$(printf '%s' "$util" | xargs)"
mem_used="$(printf '%s' "$mem_used" | xargs)"
mem_total="$(printf '%s' "$mem_total" | xargs)"
temp="$(printf '%s' "$temp" | xargs)"
power="$(printf '%s' "$power" | xargs)"
limit="$(printf '%s' "$limit" | xargs)"
printf '${color 64748B}%s${color}${alignr}${color E2E8F0}${font Adwaita Mono:size=9}%s%%${font}${color}\n' "$name" "$util"
printf '${color 475569}${font Inter:size=8}%s / %s MiB${font}${color}${alignr}${color 475569}${font Inter:size=8}%s°C · %s/%s W${font}${color}\n' "$mem_used" "$mem_total" "$temp" "$power" "$limit"
done <<< "$output"