From 1d4e450c99ef913f4a2b77fb1344b259e59ee543 Mon Sep 17 00:00:00 2001 From: Ondrej Novak Date: Fri, 19 Jun 2026 23:27:45 +0200 Subject: [PATCH] load target image path from config --- draw/src/stacked.rs | 1 + waybar-collectd/src/config.rs | 1 + waybar-collectd/src/runner.rs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/draw/src/stacked.rs b/draw/src/stacked.rs index 0871cbf..b94d41a 100644 --- a/draw/src/stacked.rs +++ b/draw/src/stacked.rs @@ -8,6 +8,7 @@ use crate::Container; pub struct StackedConfig { pub name: String, + pub path: String, pub width_px_per_sample: u32, pub height_px: u32, pub series: Vec, diff --git a/waybar-collectd/src/config.rs b/waybar-collectd/src/config.rs index 44ec344..edecec3 100644 --- a/waybar-collectd/src/config.rs +++ b/waybar-collectd/src/config.rs @@ -10,6 +10,7 @@ pub struct Config { #[derive(Debug, Deserialize)] pub struct GraphConfig { pub name: String, + pub path: String, pub width_px: u16, pub height_px: u16, pub samples: u16, diff --git a/waybar-collectd/src/runner.rs b/waybar-collectd/src/runner.rs index b1b256c..769bdfa 100644 --- a/waybar-collectd/src/runner.rs +++ b/waybar-collectd/src/runner.rs @@ -18,6 +18,7 @@ impl Graph { pub fn new(config: &GraphConfig, proto: &mut Protocol) -> Graph { let stacked_config = StackedConfig { name: config.name.to_string(), + path: config.path.to_string(), height_px: config.height_px as u32, max_samples: config.samples as u32, width_px_per_sample: (config.width_px / config.samples) as u32, @@ -90,7 +91,7 @@ impl Runner { .map_err(|e| RunnerError::CouldNotGetData(e.to_string()))?; g.series.push(sample); let img = stacked(&g.series); - img.save("cpu.png".to_string()) + img.save(g.series.config.path.to_string()) .map_err(|e| RunnerError::CouldNotSaveImage(e.to_string()))?; }