MCPcopy Index your code
hub / github.com/PolpOnline/gpu-usage-waybar

github.com/PolpOnline/gpu-usage-waybar @v0.1.26

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.26 ↗ · + Follow
51 symbols 86 edges 7 files 4 documented · 8%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

GPU USAGE WAYBAR

Crates.io Version AUR Version GitHub License

This is a simple tool I made to add GPU usage to Waybar.

It is compatible with both NVIDIA and AMD cards

Installation

Requirements

  • For NVIDIA, you need the NVML library installed

  • For AMD, the tool just uses the sysfs interface; you shouldn't need to install anything

Installation

Install with cargo

cargo install gpu-usage-waybar

Usage

Add a custom module to Waybar

Add a module to the top of the config specifying where the module should be positioned

"modules-left": ["...", "custom/gpu-usage", "..."]

Add the custom module to the config, use

"custom/gpu-usage": {
  "format": "{} {icon}", /* "{text} {icon}" for nightly users */
  "exec": "gpu-usage-waybar",
  "return-type": "json",
  "format-icons": "󰾲",
  "on-click": "ghostty -e nvtop",
}

Configuration

The crate has a configuration file (located at $XDG_CONFIG_HOME/gpu_usage_waybar.toml) which can be used to set various options about the output.

You can specify the output format in the config file as:

[text]
format = "{gpu_utilization}%|{mem_utilization}%"

[tooltip]
format = """GPU: {gpu_utilization}%
MEM USED: {mem_used}/{mem_total} MiB ({mem_utilization}%)
MEM R/W: {mem_rw}%
DEC: {decoder_utilization}%
ENC: {encoder_utilization}%
TEMP: {temperature}°C
POWER: {power}W
PSTATE: {p_state}
PLEVEL: {p_level}
FAN SPEED: {fan_speed}%
TX: {tx} MiB/s
RX: {rx} MiB/s"""

The text format defaults to "{gpu_utilization}%|{mem_utilization}%". The tooltip defaults to all fields that are supported by your GPU if not customized.

You can also set the output format with CLI args using --text-format and --tooltip-format.

Available fields

Field name Description Unit AMD NVIDIA
gpu_utilization GPU utilization %
mem_used Memory used in MiB MiB
mem_total Total memory in MiB MiB
mem_rw Memory data bus utilization %
mem_utilization Memory utilization %
decoder_utilization Decoder utilization %
encoder_utilization Encoder utilization %
temperature Temperature in degrees Celsius °C
power Power usage in Watts W
p_state (NVIDIA) Performance state NVIDIA performance state
p_level (AMD) Performance Level AMD performance level
fan_speed Fan speed in percent %
tx PCIe TX throughput in MiB/s MiB/s
rx PCIe RX throughput in MiB/s MiB/s

Bear in mind that args passed to the command line will override the configuration file

Extension points exported contracts — how you extend this code

GpuStatus (Interface)
(no doc) [2 implementers]
src/gpu_status.rs

Core symbols most depended-on inside this repo

parse
called by 3
src/formatter.rs
retain_lines_with_values
called by 3
src/config/structs.rs
get_regex
called by 2
src/formatter.rs
collect_active_gpu_stats
called by 2
src/nvidia.rs
get_field_to_string
called by 2
src/gpu_status.rs
assemble
called by 2
src/gpu_status.rs
compute
called by 2
src/amd.rs
format
called by 2
src/config/structs.rs

Shape

Method 23
Class 11
Function 11
Enum 5
Interface 1

Languages

Rust100%

Modules by API surface

src/nvidia.rs10 symbols
src/gpu_status.rs10 symbols
src/config/structs.rs10 symbols
src/main.rs7 symbols
src/formatter.rs7 symbols
src/amd.rs6 symbols
src/config/mod.rs1 symbols

For agents

$ claude mcp add gpu-usage-waybar \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page