#sfwbar VRAM Widget 07 October, 2025 sfwbar is a popular(?) taskbar for wayland window manager sessions, and it comes with CPU usage and RAM usage charts as a default. but I wanted to know my VRAM usage as well! This is very important information to be able to see at a glance whether you're gaming or trying to squeeze an LLM into memory. The version that I wrote is for NVIDIA GPUs, as that's what I have in this system, but if you have an AMD GPU it should be trivial to change one line in the gpu.source file to get the AMD numbers instead. Just create these files or download them from my Github and place them in your ~/.config/sfwbar/ directory and you should be good to go. =>https://github.com/RubyMaelstrom/sfwbar-VRAM/ Github Link gpu.source file: ``` # Use a single GPU line; -i 0 = GPU 0. Change to -i 1 if needed. scanner { Exec("nvidia-smi -i 0 --query-gpu=memory.used,memory.total --format=csv,noheader,nounits") { GpuUsedMiB = RegEx("^\\s*([0-9]+)") GpuTotalMiB = RegEx("^\\s*[0-9]+\\s*[, ]+\\s*([0-9]+)") } } Set XGpuPresent = GpuTotalMiB.count # >0 if parsed Set XGpuUtilization = If(GpuTotalMiB>0, GpuUsedMiB / GpuTotalMiB, 0) # 0..1 ``` gpu.widget file: ``` include("gpu.source") layout { chart { interval = 2000 style = If(XGpuPresent, "gpu_chart", "hidden") value = XGpuUtilization tooltip = "GPU: " + Str(XGpuUtilization*100) + '%' + ' (' + Str(GpuUsedMiB, 0) + '/' + Str(GpuTotalMiB, 0) + ' MiB)' action = Exec $Term + " -e nvidia-smi -l 1" } } ``` There's a sample sfwbar.config file on my Github, but If you want to use your existing sfwbar.config, just add this wherever you want the widget on your bar: ``` include("gpu.widget") ``` And then style your chart with this in the CSS section: ``` chart#gpu_chart { background: rgba(127,127,127,0.3); min-width: 9px; -GtkWidget-vexpand: true; margin: 2px; border: 1px solid @theme_fg_color; color: pink; } ``` Good luck and have fun! =>index.html Back