From c758268beb3e0e2f9a8839adc7e8b238111b984e Mon Sep 17 00:00:00 2001 From: jmb05 Date: Mon, 2 Nov 2026 22:02:37 +0100 Subject: [PATCH] Fix config not loading --- src/config.rs | 5 ++--- src/main.rs | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/config.rs b/src/config.rs index 3c18090..30d7385 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,11 +8,10 @@ pub struct Config { } impl Config { - pub fn load() -> Config { - fs::read_to_string("../jmb-bar.conf") + pub fn load(file_path: &str) -> Option { + fs::read_to_string(file_path) .ok() .and_then(|s| toml::from_str::(&s).ok()) - .unwrap_or_default() } } diff --git a/src/main.rs b/src/main.rs index a44ae52..dd92db5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,7 +18,11 @@ pub const APP_NAME: &str = "net.jmb19905.jmb-bar"; fn main() { info!(&LOGGER, "Starting jmb-bar"); - let config = Config::load(); + let config = Config::load("jmb-bar.conf"); + let config = config.unwrap_or_else(|| { + warn!(&LOGGER, "Couldn't load config file, using default"); + Config::default() + }); let backend = Backend::start(&config); gio::resources_register_include!("templates.gresource").expect("Failed to register resources");