From d1b1a9e006c82c0ded89c290d7f66349b6609600 Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Tue, 19 Jul 2022 09:54:15 -0700 Subject: [PATCH] fix(scoop): account for all shims on startup check This commit fixes a bug with the startup check which tries to ensure that there is only ever one instance of komorebi running at any given time. Previously, only one shim was being checked for, but if a user runs 'komorebic start' multiple times, multiple shims will be active, causing the check to mistakenly pass. The changes in this commit now account for N active shims. --- komorebi/src/main.rs | 6 +++--- komorebic.lib.sample.ahk | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/komorebi/src/main.rs b/komorebi/src/main.rs index 695e6b83..81f6d5e0 100644 --- a/komorebi/src/main.rs +++ b/komorebi/src/main.rs @@ -386,14 +386,14 @@ fn main() -> Result<()> { let matched_procs: Vec<&Process> = system.processes_by_name("komorebi.exe").collect(); if matched_procs.len() > 1 { - let mut shim_is_active = false; + let mut len = matched_procs.len(); for proc in matched_procs { if proc.root().ends_with("shims") { - shim_is_active = true; + len -= 1; } } - if !shim_is_active { + if len > 1 { tracing::error!("komorebi.exe is already running, please exit the existing process before starting a new one"); std::process::exit(1); } diff --git a/komorebic.lib.sample.ahk b/komorebic.lib.sample.ahk index 56a7e3ed..f0466f14 100644 --- a/komorebic.lib.sample.ahk +++ b/komorebic.lib.sample.ahk @@ -188,8 +188,8 @@ WorkspaceCustomLayout(monitor, workspace, path) { Run, komorebic.exe workspace-custom-layout %monitor% %workspace% %path%, , Hide } -WorkspaceLayoutRule(monitor, workspace, at_container_count, default_layout) { - Run, komorebic.exe workspace-layout-rule %monitor% %workspace% %at_container_count% %default_layout%, , Hide +WorkspaceLayoutRule(monitor, workspace, at_container_count, layout) { + Run, komorebic.exe workspace-layout-rule %monitor% %workspace% %at_container_count% %layout%, , Hide } WorkspaceCustomLayoutRule(monitor, workspace, at_container_count, path) {