From b7792a415e09fc535750ea5af530f91aa791c4bc Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Tue, 1 Nov 2022 13:25:46 +0000 Subject: [PATCH] feat: env var to set custom css location Set `IRONBAR_CSS` to load CSS from that path instead of regular path. --- src/main.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index 4d656ba..311c5f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,6 +21,7 @@ use gtk::gdk::Display; use gtk::prelude::*; use gtk::Application; use std::future::Future; +use std::path::PathBuf; use std::process::exit; use std::{env, panic}; use tokio::runtime::Handle; @@ -95,14 +96,19 @@ async fn main() -> Result<()> { debug!("Created bars"); - let style_path = config_dir().map_or_else( - || { - let report = Report::msg("Failed to locate user config dir"); - error!("{:?}", report); - exit(ErrorCode::CreateBars as i32); - }, - |dir| dir.join("ironbar").join("style.css"), - ); + let style_path = env::var("IRONBAR_CSS") + .ok() + .map(PathBuf::from) + .unwrap_or_else(|| { + config_dir().map_or_else( + || { + let report = Report::msg("Failed to locate user config dir"); + error!("{:?}", report); + exit(ErrorCode::CreateBars as i32); + }, + |dir| dir.join("ironbar").join("style.css"), + ) + }); if style_path.exists() { load_css(style_path);