mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-02 11:11:04 +02:00
feat(config): use default fallback with config instructions
When no config file is found, the bar will now automatically instead load a hard-coded default consisting of the `focused` and `clock` modules, and a `label` informing you the bar is not configured. Instructions are also printed to the log.
This commit is contained in:
parent
1a272e00fb
commit
738b9e3da7
6 changed files with 75 additions and 13 deletions
25
src/main.rs
25
src/main.rs
|
@ -47,7 +47,7 @@ use tokio::task::{block_in_place, spawn_blocking};
|
|||
|
||||
use crate::error::ExitCode;
|
||||
use clients::wayland;
|
||||
use tracing::{debug, error, info};
|
||||
use tracing::{debug, error, info, warn};
|
||||
use universal_config::ConfigLoader;
|
||||
|
||||
const GTK_APP_ID: &str = "dev.jstanger.ironbar";
|
||||
|
@ -159,18 +159,19 @@ pub fn load_interface(app: &Application) {
|
|||
|display| display,
|
||||
);
|
||||
|
||||
let config_res = env::var("IRONBAR_CONFIG").map_or_else(
|
||||
|_| ConfigLoader::new("ironbar").find_and_load(),
|
||||
ConfigLoader::load,
|
||||
);
|
||||
let mut config = env::var("IRONBAR_CONFIG")
|
||||
.map_or_else(
|
||||
|_| ConfigLoader::new("ironbar").find_and_load(),
|
||||
ConfigLoader::load,
|
||||
)
|
||||
.unwrap_or_else(|err| {
|
||||
error!("Failed to load config: {}", err);
|
||||
warn!("Falling back to the default config");
|
||||
info!("If this is your first time using Ironbar, you should create a config in ~/.config/ironbar/");
|
||||
info!("More info here: https://github.com/JakeStanger/ironbar/wiki/configuration-guide");
|
||||
|
||||
let mut config: Config = match config_res {
|
||||
Ok(config) => config,
|
||||
Err(err) => {
|
||||
error!("{:?}", err);
|
||||
exit(ExitCode::Config as i32)
|
||||
}
|
||||
};
|
||||
Config::default()
|
||||
});
|
||||
|
||||
debug!("Loaded config file");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue