oxwm

https://git.tonybtw.com/oxwm.git git://git.tonybtw.com/oxwm.git

Merge remote-tracking branch 'origin/master' into optimizations-multi-monitor

Commit
eb9146625135f10b3c1d0115d045c8d4240a55ed
Parents
bc73085 0b23d5f
Author
tonybtw <tonybtw@tonybtw.com>
Date
2025-10-23 02:41:03

Diff

diff --cc src/bin/main.rs
index d4c74f9,8496fea..cff5555
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@@ -46,24 -36,19 +46,23 @@@ fn main() -> Result<()> 
      Ok(())
  }
  
 -fn load_config() -> Result<oxwm::Config> {
 -    let config_path = get_config_path().join("config.ron");
 -
 -    if !config_path.exists() {
 -        println!("No config found at {:?}", config_path);
 -        println!("Creating default config...");
 -        init_config()?;
 -    }
 +fn load_config(custom_path: Option<PathBuf>) -> Result<oxwm::Config> {
 +    let config_path = if let Some(path) = custom_path {
 +        path
 +    } else {
 +        let default_path = get_config_path().join("config.ron");
 +        if !default_path.exists() {
 +            println!("No config found at {:?}", default_path);
 +            println!("Creating default config...");
 +            init_config()?;
 +        }
 +        default_path
 +    };
  
-     let config_str = std::fs::read_to_string(&config_path)
-         .map_err(|e| anyhow::anyhow!("Failed to read config file: {}", e))?;
+     let config_str =
+         std::fs::read_to_string(&config_path).with_context(|| "Failed to read config file")?;
  
-     oxwm::config::parse_config(&config_str)
-         .map_err(|e| anyhow::anyhow!("Failed to parse config: {}", e))
+     oxwm::config::parse_config(&config_str).with_context(|| "Failed to parse config")
  }
  
  fn init_config() -> Result<()> {