From d18283969a4fae008a93569164cb1f8aed21dfcf Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 27 Jan 2022 11:06:46 -0800 Subject: [PATCH] fix(scoop): allow duplicate shim process This commit addresses issues that users have been faced with when installing komorebi with scoop, which resulted in komorebi exiting almost immediately without providing any feedback as to what had happened. Scoop launches komorebi using an exe shim of the same name, which results in two komorebi.exe named processes running at the same time. This situation then fails the startup check which attempts to ensure that only one instance of komorebi.exe ever runs at any given time. The process startup check has been updated to allow for two komorebi.exe named processes to be running if one of them is recognised as a Scoop shim process. fix #95 --- komorebi/src/main.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 24246232..3bc374b3 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -24,6 +24,7 @@ use lazy_static::lazy_static; use parking_lot::deadlock; use parking_lot::Mutex; use serde::Serialize; +use sysinfo::ProcessExt; use sysinfo::SystemExt; use tracing_appender::non_blocking::WorkerGuard; use tracing_subscriber::layer::SubscriberExt; @@ -341,9 +342,20 @@ fn main() -> Result<()> { let mut system = sysinfo::System::new_all(); system.refresh_processes(); - if system.process_by_name("komorebi.exe").len() > 1 { - tracing::error!("komorebi.exe is already running, please exit the existing process before starting a new one"); - std::process::exit(1); + let matched_procs = system.process_by_name("komorebi.exe"); + + if matched_procs.len() > 1 { + let mut shim_is_active = false; + for proc in matched_procs { + if proc.root().ends_with("shims") { + shim_is_active = true; + } + } + + if !shim_is_active { + tracing::error!("komorebi.exe is already running, please exit the existing process before starting a new one"); + std::process::exit(1); + } } // File logging worker guard has to have an assignment in the main fn to work