tony / oxwm

updated rebuild function to be smart about existing file. Browse files
tonybtw committed 2025-10-11 parent 4001329 commit 15bb7a7cf0961a18f51a87f9594b4b9c36c7ae95
Showing 2 changed files with 11 additions and 25 deletions. UnifiedSplit
+11 −2 src/bin/main.rs
@@ -32,7 +32,6 @@ fn main() -> Result<()> {
32 let err = Command::new(&cache_binary).args(&args[1..]).exec(); 32 let err = Command::new(&cache_binary).args(&args[1..]).exec();
33 anyhow::bail!("Failed to exec user binary: {}", err); 33 anyhow::bail!("Failed to exec user binary: {}", err);
34 } else { 34 } else {
35 - // No user config - use built-in defaults
36 eprintln!("╔════════════════════════════════════════╗"); 35 eprintln!("╔════════════════════════════════════════╗");
37 eprintln!("║ OXWM: Running with default config ║"); 36 eprintln!("║ OXWM: Running with default config ║");
38 eprintln!("╚════════════════════════════════════════╝"); 37 eprintln!("╚════════════════════════════════════════╝");
@@ -41,6 +40,7 @@ fn main() -> Result<()> {
41 eprintln!(); 40 eprintln!();
42 41
43 let config = oxwm::Config::default(); 42 let config = oxwm::Config::default();
43 +
44 let mut wm = oxwm::window_manager::WindowManager::new(config)?; 44 let mut wm = oxwm::window_manager::WindowManager::new(config)?;
45 let should_restart = wm.run()?; 45 let should_restart = wm.run()?;
46 46
@@ -198,7 +198,16 @@ fn recompile_config() -> Result<()> {
198 let dest = get_cache_binary_path(); 198 let dest = get_cache_binary_path();
199 199
200 std::fs::create_dir_all(dest.parent().unwrap())?; 200 std::fs::create_dir_all(dest.parent().unwrap())?;
201 - std::fs::copy(&source, &dest)?; 201 +
202 + match std::fs::copy(&source, &dest) {
203 + Ok(_) => {}
204 + Err(e) if e.raw_os_error() == Some(26) => {
205 + let temp_dest = dest.with_extension("new");
206 + std::fs::copy(&source, &temp_dest)?;
207 + std::fs::rename(&temp_dest, &dest)?;
208 + }
209 + Err(e) => return Err(e.into()),
210 + }
202 211
203 println!("✓ Compiled successfully"); 212 println!("✓ Compiled successfully");
204 213
+0 −23 src/main.rs deleted file mode 100644
@@ -1,23 +0,0 @@
1 -use anyhow::Result;
2 -mod bar;
3 -mod config;
4 -mod keyboard;
5 -mod layout;
6 -mod window_manager;
7 -
8 -fn main() -> Result<()> {
9 - let args: Vec<String> = std::env::args().collect();
10 -
11 - let mut window_manager = window_manager::WindowManager::new()?;
12 - let should_restart = window_manager.run()?;
13 -
14 - drop(window_manager);
15 -
16 - if should_restart {
17 - use std::os::unix::process::CommandExt;
18 - let err = std::process::Command::new(&args[0]).args(&args[1..]).exec();
19 - eprintln!("Failed to restart: {}", err);
20 - }
21 -
22 - Ok(())
23 -}