Skip to content

Commit

Permalink
perf(cli): validate komorebi proc earlier on start
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
LGUG2Z committed Dec 7, 2024
1 parent f227bd0 commit 280ca0f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions komorebic/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit 280ca0f

Please sign in to comment.