Add NVIDIA statistics to the i3 bar

nvidia-smi can output various monitoring data.

  • nvidia-smi dmon -c 1 -s p fetch temparature and power once
  • tail -1 use only the last line
  • sed -E 's/ *. *?([0-9]*) *?([0-9]*).*/GPU: \1 Watt @ \2°C/' extract the two numbers into the text to show
command=nvidia-smi dmon -c 1 -s p | tail -1 | sed -E 's/ *. *?([0-9]*) *?([0-9]*).*/GPU: \1 Watt @ \2°C/'

I use i3wm and i3blocks here.

sudo apt install i3
sudo apt install i3blocks