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:
22
src/main.rs
22
src/main.rs
@@ -21,6 +21,7 @@ use gtk::gdk::Display;
|
|||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
use gtk::Application;
|
use gtk::Application;
|
||||||
use std::future::Future;
|
use std::future::Future;
|
||||||
|
use std::path::PathBuf;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use std::{env, panic};
|
use std::{env, panic};
|
||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
@@ -95,14 +96,19 @@ async fn main() -> Result<()> {
|
|||||||
|
|
||||||
debug!("Created bars");
|
debug!("Created bars");
|
||||||
|
|
||||||
let style_path = config_dir().map_or_else(
|
let style_path = env::var("IRONBAR_CSS")
|
||||||
|| {
|
.ok()
|
||||||
let report = Report::msg("Failed to locate user config dir");
|
.map(PathBuf::from)
|
||||||
error!("{:?}", report);
|
.unwrap_or_else(|| {
|
||||||
exit(ErrorCode::CreateBars as i32);
|
config_dir().map_or_else(
|
||||||
},
|
|| {
|
||||||
|dir| dir.join("ironbar").join("style.css"),
|
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() {
|
if style_path.exists() {
|
||||||
load_css(style_path);
|
load_css(style_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user