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")"
|
||||
@@ -26,6 +26,7 @@ Config { overrideRedirect = True
|
||||
, "--normal" , "#ffb86c"
|
||||
, "--high" , "#ff5555"
|
||||
] 50
|
||||
, Run Com "/home/fuxino/.config/xmobar/gpu.sh" [] "gpu" 50
|
||||
, Run Memory
|
||||
[ "--template" , "\xefc5 <usedratio>%"
|
||||
, "--Low" , "50"
|
||||
@@ -49,5 +50,5 @@ Config { overrideRedirect = True
|
||||
]
|
||||
, sepChar = "%"
|
||||
, alignSep = "}{"
|
||||
, template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% "
|
||||
, template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %gpu% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% "
|
||||
}
|
||||
@@ -26,6 +26,7 @@ Config { overrideRedirect = True
|
||||
, "--normal" , "#ffb86c"
|
||||
, "--high" , "#ff5555"
|
||||
] 50
|
||||
, Run Com "/home/fuxino/.config/xmobar/gpu.sh" [] "gpu" 50
|
||||
, Run Memory
|
||||
[ "--template" , "\xefc5 <usedratio>%"
|
||||
, "--Low" , "50"
|
||||
@@ -50,5 +51,5 @@ Config { overrideRedirect = True
|
||||
]
|
||||
, sepChar = "%"
|
||||
, alignSep = "}{"
|
||||
, template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% %_XMONAD_TRAYPAD% "
|
||||
, template = " | %UnsafeXMonadLog% } %multicpu% %coretemp% | %gpu% | %memory% | <action=`/home/fuxino/.config/xmobar/kbd_cycle.sh` button=1><action=`/home/fuxino/.config/xmobar/kbd_cycle.sh prev` button=3> %kbd%</action></action> { <action=`/home/fuxino/.config/xmobar/calcurse.sh list` button=1><action=`xdotool key super+shift+a` button=3>%calcurse%</action></action><action=`/home/fuxino/.config/xmobar/backup.sh list`>%backup%</action><action=`/home/fuxino/.config/xmobar/updates.sh list`>%updates%</action><action=`/home/fuxino/.config/xmobar/weather.sh notify`>%weather%</action> <fc=#565f89>·</fc> <action=`/home/fuxino/.config/xmobar/ens_brief.sh week`>%ens_brief%</action> | <action=`pactl set-sink-mute @DEFAULT_SINK@ toggle` button=1>%pactl_volume%</action> | %date% %_XMONAD_TRAYPAD% "
|
||||
}
|
||||
Reference in new issue
Block a user