mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 18:51: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
|
@ -21,6 +21,7 @@ use crate::modules::tray::TrayModule;
|
|||
use crate::modules::upower::UpowerModule;
|
||||
#[cfg(feature = "workspaces")]
|
||||
use crate::modules::workspaces::WorkspacesModule;
|
||||
use cfg_if::cfg_if;
|
||||
use serde::Deserialize;
|
||||
use std::collections::HashMap;
|
||||
|
||||
|
@ -109,6 +110,35 @@ pub struct Config {
|
|||
pub monitors: Option<HashMap<String, MonitorConfig>>,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
cfg_if! {
|
||||
if #[cfg(feature = "clock")] {
|
||||
let end = Some(vec![ModuleConfig::Clock(Box::default())]);
|
||||
}
|
||||
else {
|
||||
let end = None;
|
||||
}
|
||||
}
|
||||
|
||||
Self {
|
||||
position: Default::default(),
|
||||
height: default_bar_height(),
|
||||
margin: Default::default(),
|
||||
popup_gap: default_popup_gap(),
|
||||
icon_theme: None,
|
||||
ironvar_defaults: None,
|
||||
start: Some(vec![ModuleConfig::Label(
|
||||
LabelModule::new("ℹ️ Using default config".to_string()).into(),
|
||||
)]),
|
||||
center: Some(vec![ModuleConfig::Focused(Box::default())]),
|
||||
end,
|
||||
anchor_to_edges: default_true(),
|
||||
monitors: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn default_bar_height() -> i32 {
|
||||
42
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue