Compare commits

..

No commits in common. "2518c92ca33f3199ae19a046b550e42b4a47ec9e" and "92196dcbf85120d8b5c73a7422e0b0e9aff693db" have entirely different histories.

4 changed files with 7 additions and 90 deletions

View File

@ -1,82 +0,0 @@
# 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
}
}
]
```

View File

@ -1,10 +1,9 @@
[global] [global]
period = 1 period = 1
socket = "/var/run/collectd-unixsock"
[[graph]] [[graph]]
name = "cpu load" name = "cpu load"
path = "/tmp/waybar-graphs/cpu.png" path = "cpu.png"
width_px = 480 width_px = 480
height_px = 98 height_px = 98
samples = 60 samples = 60
@ -39,7 +38,7 @@ metrics = [
[[graph]] [[graph]]
name = "memory" name = "memory"
path = "/tmp/waybar-graphs/mem.png" path = "mem.png"
width_px = 480 width_px = 480
height_px = 98 height_px = 98
samples = 90 samples = 90
@ -68,7 +67,7 @@ metrics = [
[[graph]] [[graph]]
name = "disk" name = "disk"
path = "/tmp/waybar-graphs/disk.png" path = "disk.png"
width_px = 480 width_px = 480
height_px = 98 height_px = 98
samples = 90 samples = 90
@ -89,7 +88,7 @@ metrics = [
[[graph]] [[graph]]
name = "network" name = "network"
path = "/tmp/waybar-graphs/net.png" path = "net.png"
width_px = 480 width_px = 480
height_px = 98 height_px = 98
samples = 90 samples = 90

View File

@ -11,7 +11,6 @@ pub struct Config {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
pub struct Global { pub struct Global {
pub period: f32, pub period: f32,
pub socket: String,
} }
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]

View File

@ -19,8 +19,9 @@ struct Cli {
fn main() { fn main() {
let args = Cli::parse(); let args = Cli::parse();
let config = parse(&args.config); if let Ok(mut proto) = Protocol::new("/var/run/collectd-unixsock") {
if let Ok(mut proto) = Protocol::new(&config.global.socket) { let config = parse(&args.config);
let graphs = config let graphs = config
.graph .graph
.iter() .iter()