tony / oxwm

Integrated recent updates into my pull request. Browse files
Scott DeJong committed 2025-12-23 parent 19b2885 commit 0522a394f723ad12a82d39c3d34d10436fbcc21a
Showing 1 changed file with 12 additions and 8 deletions. UnifiedSplit
+12 −8 src/bin/main.rs
@@ -1,3 +1,4 @@
1 +use oxwm::errors::ConfigError;
1 2 use oxwm::errors::MainError;
2 3 use std::path::Path;
3 4 use std::path::PathBuf;
@@ -18,14 +19,15 @@ fn main() -> Result<(), MainError> {
18 19 Args::Error(e) => return Err(e),
19 20 };
20 21
21 - let (config, had_broken_config) = load_config(arguments.get(2))?;
22 + let (config, config_warning) = load_config(arguments.get(2))?;
22 23
23 24 let mut window_manager = match oxwm::window_manager::WindowManager::new(config) {
24 25 Ok(wm) => wm,
25 26 Err(e) => return Err(MainError::CouldNotStartWm(e)),
26 27 };
27 28
28 - if had_broken_config {
29 + if let Some(warning) = config_warning {
30 + eprintln!("{warning}");
29 31 window_manager.show_migration_overlay();
30 32 }
31 33
@@ -46,7 +48,9 @@ fn main() -> Result<(), MainError> {
46 48 Ok(())
47 49 }
48 50
49 -fn load_config(config_path: Option<&String>) -> Result<(oxwm::Config, bool), MainError> {
51 +fn load_config(
52 + config_path: Option<&String>,
53 +) -> Result<(oxwm::Config, Option<ConfigError>), MainError> {
50 54 let path = match config_path {
51 55 None => {
52 56 let config_dir = get_config_path()?;
@@ -64,19 +68,19 @@ fn load_config(config_path: Option<&String>) -> Result<(oxwm::Config, bool), Mai
64 68
65 69 let config_directory = path.parent();
66 70
67 - let (mut config, had_broken_config) =
71 + let (mut config, config_warning) =
68 72 match oxwm::config::parse_lua_config(&config_string, config_directory) {
69 - Ok(config) => (config, false),
70 - Err(_error) => {
73 + Ok(config) => (config, None),
74 + Err(warning) => {
71 75 let config = match oxwm::config::parse_lua_config(TEMPLATE, None) {
72 76 Ok(c) => c,
73 77 Err(e) => return Err(MainError::FailedReadConfigTemplate(e)),
74 78 };
75 - (config, true)
79 + (config, Some(warning))
76 80 }
77 81 };
78 82 config.path = Some(path);
79 - Ok((config, had_broken_config))
83 + Ok((config, config_warning))
80 84 }
81 85
82 86 fn init_config() -> Result<(), MainError> {