Setting config.path to enable hot-reload of changed config file
Browse files
+12 −9 src/bin/main.rs
| @@ -65,15 +65,18 @@ fn load_config( | ||
| 65 | 65 | |
| 66 | 66 | let config_directory = path.parent(); |
| 67 | 67 | |
| 68 | - match oxwm::config::parse_lua_config(&config_string, config_directory) { | |
| 69 | - Ok(config) => Ok((config, false)), | |
| 70 | - Err(_error) => { | |
| 71 | - let config = oxwm::config::parse_lua_config(TEMPLATE, None).map_err(|error| { | |
| 72 | - format!("Error: Failed to parse default template config:\n{}", error) | |
| 73 | - })?; | |
| 74 | - Ok((config, true)) | |
| 75 | - } | |
| 76 | - } | |
| 68 | + let (mut config, had_broken_config) = | |
| 69 | + match oxwm::config::parse_lua_config(&config_string, config_directory) { | |
| 70 | + Ok(config) => (config, false), | |
| 71 | + Err(_error) => { | |
| 72 | + let config = oxwm::config::parse_lua_config(TEMPLATE, None).map_err(|error| { | |
| 73 | + format!("Error: Failed to parse default template config:\n{}", error) | |
| 74 | + })?; | |
| 75 | + (config, true) | |
| 76 | + } | |
| 77 | + }; | |
| 78 | + config.path = Some(path); | |
| 79 | + Ok((config, had_broken_config)) | |
| 77 | 80 | } |
| 78 | 81 | |
| 79 | 82 | fn init_config() -> Result<(), Box<dyn std::error::Error>> { |