waybar-collectd/README.md

83 lines
2.0 KiB
Markdown
Raw Normal View History

2026-07-06 22:51:14 +02:00
# 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
```bash
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`):**
```conf
Interval 1 # Sample data every 1 second
LoadPlugin unixsock
# Enable the plugins you want to use
LoadPlugin cpu
LoadPlugin memory
LoadPlugin disk
LoadPlugin network
```
```bash
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`
```ini
[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`):**
```json
[
{
"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
}
}
]
```