fix theme attrs being unset because they get set before theme.reset

This commit is contained in:
emilis 2024-03-01 23:05:54 +00:00
parent 01c5752868
commit bda9b4d969
2 changed files with 17 additions and 7 deletions

View File

@ -196,7 +196,7 @@ impl Config {
Ok(format!( Ok(format!(
"{home}/.config/herbstluftwm/hlctl.toml", "{home}/.config/herbstluftwm/hlctl.toml",
home = env::var("XDG_CONFIG_HOME") 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"); info!("loading attr settings command set");
Ok([ Ok([
(Self::FONT, Some(self.font.clone())), (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_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, Self::SERVICES,
if self.services.len() == 0 { if self.services.len() == 0 {
@ -230,6 +231,7 @@ impl Config {
Some(serde_json::ser::to_string(&self.services)?) Some(serde_json::ser::to_string(&self.services)?)
}, },
), ),
(Self::MOD_KEY, Some(self.mod_key.to_string())),
] ]
.into_iter() .into_iter()
.filter(|(_, attr)| attr.is_some()) .filter(|(_, attr)| attr.is_some())
@ -326,8 +328,8 @@ impl Config {
.into_iter() .into_iter()
.map(|mb| HlwmCommand::Mousebind(mb)), .map(|mb| HlwmCommand::Mousebind(mb)),
) )
.chain(self.attrs_set()?)
.chain(self.theme_command_set()) .chain(self.theme_command_set())
.chain(self.attrs_set()?)
.chain(self.tag_command_set()) .chain(self.tag_command_set())
.chain(self.settings_command_set()) .chain(self.settings_command_set())
.chain(self.rule_command_set()) .chain(self.rule_command_set())

View File

@ -53,8 +53,16 @@ fn main() {
} }
} }
fn load_or_default_config() -> Config { fn load_config() -> Config {
Config::from_file(&Path::new(&Config::default_path().unwrap())).unwrap_or_log(Config::default()) 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) { fn x_set_root(path: PathBuf) {
@ -79,7 +87,7 @@ fn init() {
info!("loading config"); info!("loading config");
hlwm::Client::new() hlwm::Client::new()
.execute_iter( .execute_iter(
load_or_default_config() load_config()
.to_command_set() .to_command_set()
.expect("marshalling init command set"), .expect("marshalling init command set"),
) )
@ -87,7 +95,7 @@ fn init() {
} }
fn merged_config() -> Config { fn merged_config() -> Config {
let default = load_or_default_config(); let default = load_config();
let mut collected = Config::from_herbstluft(); let mut collected = Config::from_herbstluft();
collected.tags = default.tags; collected.tags = default.tags;