Fix config not loading
This commit is contained in:
@@ -8,11 +8,10 @@ pub struct Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Config {
|
impl Config {
|
||||||
pub fn load() -> Config {
|
pub fn load(file_path: &str) -> Option<Config> {
|
||||||
fs::read_to_string("../jmb-bar.conf")
|
fs::read_to_string(file_path)
|
||||||
.ok()
|
.ok()
|
||||||
.and_then(|s| toml::from_str::<Config>(&s).ok())
|
.and_then(|s| toml::from_str::<Config>(&s).ok())
|
||||||
.unwrap_or_default()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ pub const APP_NAME: &str = "net.jmb19905.jmb-bar";
|
|||||||
fn main() {
|
fn main() {
|
||||||
info!(&LOGGER, "Starting jmb-bar");
|
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);
|
let backend = Backend::start(&config);
|
||||||
|
|
||||||
gio::resources_register_include!("templates.gresource").expect("Failed to register resources");
|
gio::resources_register_include!("templates.gresource").expect("Failed to register resources");
|
||||||
|
|||||||
Reference in New Issue
Block a user