From bda9b4d9696688b19cd7ab3032ed3ef6eadc2af2 Mon Sep 17 00:00:00 2001 From: emilis Date: Fri, 1 Mar 2024 23:05:54 +0000 Subject: [PATCH] fix theme attrs being unset because they get set before theme.reset --- src/config.rs | 8 +++++--- src/main.rs | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/config.rs b/src/config.rs index 68ff7e7..df63c57 100644 --- a/src/config.rs +++ b/src/config.rs @@ -196,7 +196,7 @@ impl Config { Ok(format!( "{home}/.config/herbstluftwm/hlctl.toml", home = env::var("XDG_CONFIG_HOME") - .unwrap_or_log(env::var("HOME").map_err(|_| ConfigError::HomeNotSet)?) + .unwrap_or(env::var("HOME").map_err(|_| ConfigError::HomeNotSet)?) )) } @@ -220,8 +220,9 @@ impl Config { info!("loading attr settings command set"); Ok([ (Self::FONT, Some(self.font.clone())), - (Self::MOD_KEY, Some(self.mod_key.to_string())), (Self::FONT_BOLD, Some(self.font_bold.clone())), + (Self::FONT_PANGO, Some(self.font_pango.clone())), + (Self::FONT_PANGO_BOLD, Some(self.font_pango_bold.clone())), ( Self::SERVICES, if self.services.len() == 0 { @@ -230,6 +231,7 @@ impl Config { Some(serde_json::ser::to_string(&self.services)?) }, ), + (Self::MOD_KEY, Some(self.mod_key.to_string())), ] .into_iter() .filter(|(_, attr)| attr.is_some()) @@ -326,8 +328,8 @@ impl Config { .into_iter() .map(|mb| HlwmCommand::Mousebind(mb)), ) - .chain(self.attrs_set()?) .chain(self.theme_command_set()) + .chain(self.attrs_set()?) .chain(self.tag_command_set()) .chain(self.settings_command_set()) .chain(self.rule_command_set()) diff --git a/src/main.rs b/src/main.rs index ebb0ce8..63142b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,8 +53,16 @@ fn main() { } } -fn load_or_default_config() -> Config { - Config::from_file(&Path::new(&Config::default_path().unwrap())).unwrap_or_log(Config::default()) +fn load_config() -> Config { + match Config::from_file(&Path::new(&Config::default_path().unwrap())) { + Ok(cfg) => cfg, + Err(err) => { + error!("Could not load config. Error: {err}"); + error!(""); + error!("Hint: try calling `hlctl save` to save a default or collected config"); + std::process::exit(1); + } + } } fn x_set_root(path: PathBuf) { @@ -79,7 +87,7 @@ fn init() { info!("loading config"); hlwm::Client::new() .execute_iter( - load_or_default_config() + load_config() .to_command_set() .expect("marshalling init command set"), ) @@ -87,7 +95,7 @@ fn init() { } fn merged_config() -> Config { - let default = load_or_default_config(); + let default = load_config(); let mut collected = Config::from_herbstluft(); collected.tags = default.tags;