From 280ca0ffcd4f3e64770eec27532e1b12646820cb Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Sat, 7 Dec 2024 10:57:48 -0800 Subject: [PATCH] perf(cli): validate komorebi proc earlier on start This is a small change to the start command which moves the check for the komorebi processes to come a little bit earlier. This small change will make running commands like "komorebic start --bar" around 3s faster when komorebi is already running. --- komorebic/src/main.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/komorebic/src/main.rs b/komorebic/src/main.rs index 84ee71da4..c00e9274c 100644 --- a/komorebic/src/main.rs +++ b/komorebic/src/main.rs @@ -1990,8 +1990,14 @@ fn main() -> Result<()> { ) }; + let mut system = sysinfo::System::new_all(); + system.refresh_processes(ProcessesToUpdate::All); + let mut attempts = 0; - let mut running = false; + let mut running = system + .processes_by_name("komorebi.exe".as_ref()) + .next() + .is_some(); while !running && attempts <= 2 { match powershell_script::run(&script) { @@ -2006,7 +2012,6 @@ fn main() -> Result<()> { print!("Waiting for komorebi.exe to start..."); std::thread::sleep(Duration::from_secs(3)); - let mut system = sysinfo::System::new_all(); system.refresh_processes(ProcessesToUpdate::All); if system