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 | let config_directory = path.parent(); | 66 | let config_directory = path.parent(); |
| 67 | 67 | ||
| 68 | - match oxwm::config::parse_lua_config(&config_string, config_directory) { | 68 | + let (mut config, had_broken_config) = |
| 69 | - Ok(config) => Ok((config, false)), | 69 | + match oxwm::config::parse_lua_config(&config_string, config_directory) { |
| 70 | - Err(_error) => { | 70 | + Ok(config) => (config, false), |
| 71 | - let config = oxwm::config::parse_lua_config(TEMPLATE, None).map_err(|error| { | 71 | + Err(_error) => { |
| 72 | - format!("Error: Failed to parse default template config:\n{}", error) | 72 | + let config = oxwm::config::parse_lua_config(TEMPLATE, None).map_err(|error| { |
| 73 | - })?; | 73 | + format!("Error: Failed to parse default template config:\n{}", error) |
| 74 | - Ok((config, true)) | 74 | + })?; |
| 75 | - } | 75 | + (config, true) |
| 76 | - } | 76 | + } |
| 77 | + }; | ||
| 78 | + config.path = Some(path); | ||
| 79 | + Ok((config, had_broken_config)) | ||
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | fn init_config() -> Result<(), Box<dyn std::error::Error>> { | 82 | fn init_config() -> Result<(), Box<dyn std::error::Error>> { |