Show graphics card (NVIDIA) temp and mem usage
[khatus.git] / bin / khatus_show
index 03ad6a9..c0a41a1 100755 (executable)
@@ -342,11 +342,42 @@ mpd_state=$(
         '
 )
 
+mpd_current_file=$(
+    echo 'currentsong' \
+    | nc 127.0.0.1 6600 \
+    | awk -v max_chars=10 '
+        /^file:/ {
+            file = $2
+            for (i=3; i<=NF; i++) {file = file " " $i}
+            last = split(file, parts, "/")
+            print substr(parts[last], 1, max_chars)
+        }
+        '
+)
+
+graphics_card=$(
+    nvidia-smi \
+        --format=csv,noheader,nounits \
+        --query-gpu=memory.total,memory.used,temperature.gpu \
+    | awk -F ',' '
+        {
+            mem_total = $1;
+            mem_used  = $2;
+            temp      = $3;
+            mem_used_percent = (100 * mem_used) / mem_total;
+            printf("[%d%% %dC]", mem_used_percent, temp);
+        }
+        '
+)
+
 echo \
 "\
  E$energy\
  \
  \
+ G=$graphics_card\
+ \
+ \
  M$memory\
  \
  \
@@ -370,7 +401,7 @@ echo \
  \
  V=$volume\
  \
$mpd_state\
[$mpd_state $mpd_current_file]\
  \
  $signal_last_msg_age\
  \
This page took 0.026054 seconds and 4 git commands to generate.