1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

feat: env var to set custom css location

Set `IRONBAR_CSS` to load CSS from that path instead of regular path.
This commit is contained in:
Jake Stanger 2022-11-01 13:25:46 +00:00
parent 9f82ba58cd
commit b7792a415e
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61

View file

@ -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);