oxwm

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

Added proper error message for first load of oxwm.

Commit
6d17811ab27a0e8a7603a33f0a4a9c2953991ce2
Parent
35465e8
Author
tonybtw <tonybtw@tonybtw.com>
Date
2025-12-22 05:50:53

Diff

diff --git a/Cargo.lock b/Cargo.lock
index 7143af8..da09923 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -291,7 +291,7 @@ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
 
 [[package]]
 name = "oxwm"
-version = "0.9.0"
+version = "0.9.1"
 dependencies = [
  "chrono",
  "dirs",
diff --git a/Cargo.toml b/Cargo.toml
index a30350a..4b78a5f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "oxwm"
-version = "0.9.0"
+version = "0.9.1"
 edition = "2024"
 
 [lib]
diff --git a/resources/test-config.lua b/resources/test-config.lua
index d9765f1..74373b9 100644
--- a/resources/test-config.lua
+++ b/resources/test-config.lua
@@ -28,6 +28,8 @@ local colors = {
     blue = 0x6dade3,
 }
 
+asdf
+
 local modkey = "Mod1"
 
 oxwm.set_terminal("st")
diff --git a/src/bin/main.rs b/src/bin/main.rs
index 1e4ab21..0b3297d 100644
--- a/src/bin/main.rs
+++ b/src/bin/main.rs
@@ -29,12 +29,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
         _ => {}
     }
 
-    let (config, had_broken_config) = load_config(custom_config_path)?;
+    let (config, config_error) = load_config(custom_config_path)?;
 
     let mut window_manager = oxwm::window_manager::WindowManager::new(config)?;
 
-    if had_broken_config {
-        window_manager.show_migration_overlay();
+    if let Some(error) = config_error {
+        window_manager.show_startup_config_error(&error);
     }
 
     let should_restart = window_manager.run()?;
@@ -54,7 +54,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
 
 fn load_config(
     custom_path: Option<PathBuf>,
-) -> Result<(oxwm::Config, bool), Box<dyn std::error::Error>> {
+) -> Result<(oxwm::Config, Option<String>), Box<dyn std::error::Error>> {
     let config_path = if let Some(path) = custom_path {
         path
     } else {
@@ -86,21 +86,21 @@ fn load_config(
 
     let config_directory = config_path.parent();
 
-    let (mut config, had_error) =
+    let (mut config, config_error) =
         match oxwm::config::parse_lua_config(&config_string, config_directory) {
-            Ok(config) => (config, false),
-            Err(_error) => {
+            Ok(config) => (config, None),
+            Err(error) => {
                 let template = include_str!("../../templates/config.lua");
                 let config = oxwm::config::parse_lua_config(template, None).map_err(|error| {
                     format!("Failed to parse default template config: {}", error)
                 })?;
-                (config, true)
+                (config, Some(format!("{}", error)))
             }
         };
 
     config.path = Some(config_path);
 
-    Ok((config, had_error))
+    Ok((config, config_error))
 }
 
 fn init_config() -> Result<(), Box<dyn std::error::Error>> {
diff --git a/src/window_manager.rs b/src/window_manager.rs
index e8f9ecc..b9d58ae 100644
--- a/src/window_manager.rs
+++ b/src/window_manager.rs
@@ -312,16 +312,7 @@ impl WindowManager {
         Ok(window_manager)
     }
 
-    pub fn show_migration_overlay(&mut self) {
-        let message = "We are on version 0.8.0 now.\n\n\
-                       Your config file has been deprecated once again.\n\
-                       Backup your current config, and run oxwm --init to generate a new one with correct values.\n\n\
-                       Please reach out to Tony, or check out the\n\
-                       documentation for help with migration.\n\n\
-                       We appreciate you testing oxwm!\n\n\
-                       Press Mod+Shift+/ to see keybinds\n\
-                       Press Mod+Shift+R to reload after fixing your config";
-
+    pub fn show_startup_config_error(&mut self, error: &str) {
         let monitor = &self.monitors[self.selected_monitor];
         let monitor_x = monitor.screen_x as i16;
         let monitor_y = monitor.screen_y as i16;
@@ -331,13 +322,13 @@ impl WindowManager {
         if let Err(e) = self.overlay.show_error(
             &self.connection,
             &self.font,
-            message,
+            error,
             monitor_x,
             monitor_y,
             screen_width,
             screen_height,
         ) {
-            eprintln!("Failed to show migration overlay: {:?}", e);
+            eprintln!("Failed to show config error overlay: {:?}", e);
         }
     }