waybar-collectd/README.md

2.1 KiB

waybar-collectd

A Waybar graphing utility inspired by the Gnome 2 Panel system indicator. It uses collectd's unixsock plugin to gather metrics and renders images for the waybar-image plugin.

Installation

cargo install --git https://forgejo.cerno.ch/handy/waybar-collectd.git

Configuring collectd

Install and configure collectd with the unixsock plugin. For per-second updates, adjust the sampling interval. Ensure collectd is enabled to start on boot.

Example config (/etc/collectd.d/waybar.conf):

Interval 1  # Sample data every 1 second

LoadPlugin unixsock
<Plugin unixsock>
	SocketPerms "0666"
</Plugin>


# Enable the plugins you want to use
LoadPlugin cpu
LoadPlugin memory
LoadPlugin disk
LoadPlugin network
sudo systemctl enable --now collectd

Configuring waybar-collectd

Define your graphs and data sources in config.toml. To ensure the daemon runs on login, use a user systemd unit or your WM configuration.

User systemd unit example

~/.config/systemd/user/waybar-hwmonitor-daemon.service

[Unit]
Description=Data collection daemon for waybar hw monitor

[Service]
Type=simple
ExecStart=%h/.cargo/bin/waybar-collectd --config %h/.config/waybar/modules/waybar-collectd-config.toml
Restart=on-failure
RestartSec=2s

[Install]
WantedBy=default.target

Configuring Waybar

Add a module for each graph to your Waybar config. Ensure the size matches the rendered image dimensions.

Example config (~/.config/waybar/config):

[
	{
    "layer": "bottom",
    "position": "top",
		"modules-center": ["image#net", "image#disk", "image#mem", "image#cpu"],
		"height": 24,
    "image#cpu": {
        "path": "/tmp/waybar-graphs/cpu.png",
        "size": 120,
        "interval": 1
    },
    "image#mem": {
        "path": "/tmp/waybar-graphs/mem.png",
        "size": 120,
        "interval": 1
    },
    "image#disk": {
        "path": "/tmp/waybar-graphs/disk.png",
        "size": 120,
        "interval": 1
    },
    "image#net": {
        "path": "/tmp/waybar-graphs/net.png",
        "size": 120,
        "interval": 1
    }		
	}
]