xmobar: show NVIDIA GPU load and temperature
Add gpu.sh, which reads both values from nvidia-smi and colors them like the CPU ones (load 25/75, temp 75/90), and show it between CPU and memory.
This commit is contained in:
3 files changed
+21
-2
No files matched your search
Executable
+17
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# NVIDIA GPU load and temperature for xmobar, e.g. "<icon> 9% 68°C", colored like the CPU ones.
|
||||
# Load 25/75 as MultiCpu; temperature 75/90 (GTX 1050 Ti Mobile: target 94°C, ~65°C driving the HDMI output).
|
||||
|
||||
color() { # value low high
|
||||
if (( $1 > $3 )); then c='#ff5555'; elif (( $1 > $2 )); then c='#ffb86c'; else c='#50fa7b'; fi
|
||||
printf '<fc=%s>%s</fc>' "$c" "$4"
|
||||
}
|
||||
|
||||
icon=$'\U000f08ae'
|
||||
IFS=', ' read -r load temp < <(nvidia-smi --query-gpu=utilization.gpu,temperature.gpu --format=csv,noheader,nounits 2>/dev/null)
|
||||
if [[ ! $load =~ ^[0-9]+$ || ! $temp =~ ^[0-9]+$ ]]; then
|
||||
echo "$icon N/A"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "$icon $(color "$load" 25 75 "$load%") $(color "$temp" 75 90 "$temp°C")"
|
||||
Reference in new issue
Block a user