diff --git a/.config/xmobar/gpu.sh b/.config/xmobar/gpu.sh new file mode 100755 index 0000000..b97c2f0 --- /dev/null +++ b/.config/xmobar/gpu.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# NVIDIA GPU load and temperature for xmobar, e.g. " 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 '%s' "$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")" diff --git a/.config/xmobar/xmobarrc_hdmi b/.config/xmobar/xmobarrc_hdmi index bb7dc17..48647df 100644 --- a/.config/xmobar/xmobarrc_hdmi +++ b/.config/xmobar/xmobarrc_hdmi @@ -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 %" , "--Low" , "50" @@ -49,5 +50,5 @@ Config { overrideRedirect = True ] , sepChar = "%" , alignSep = "}{" - , template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% |  %kbd% { %calcurse%%backup%%updates%%weather% · %ens_brief% | %pactl_volume% | %date% " + , template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %gpu% | %memory% |  %kbd% { %calcurse%%backup%%updates%%weather% · %ens_brief% | %pactl_volume% | %date% " } diff --git a/.config/xmobar/xmobarrc_laptop b/.config/xmobar/xmobarrc_laptop index 40a22b3..5f8a68c 100644 --- a/.config/xmobar/xmobarrc_laptop +++ b/.config/xmobar/xmobarrc_laptop @@ -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 %" , "--Low" , "50" @@ -50,5 +51,5 @@ Config { overrideRedirect = True ] , sepChar = "%" , alignSep = "}{" - , template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %memory% |  %kbd% { %calcurse%%backup%%updates%%weather% · %ens_brief% | %pactl_volume% | %date% %_XMONAD_TRAYPAD% " + , template = "  | %UnsafeXMonadLog% } %multicpu% %coretemp% | %gpu% | %memory% |  %kbd% { %calcurse%%backup%%updates%%weather% · %ens_brief% | %pactl_volume% | %date% %_XMONAD_TRAYPAD% " }