From 8c7bff15d99bd5e9b929192eb686580abb163847 Mon Sep 17 00:00:00 2001 From: Lars Berger Date: Tue, 28 Jan 2025 17:52:54 +0000 Subject: [PATCH] fix: running `glazewm` without arguments in shell causes recursive self-launching (#949) --- packages/wm-cli/src/main.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/wm-cli/src/main.rs b/packages/wm-cli/src/main.rs index eeb31eef..ed86724f 100644 --- a/packages/wm-cli/src/main.rs +++ b/packages/wm-cli/src/main.rs @@ -11,7 +11,8 @@ async fn main() -> anyhow::Result<()> { match app_command { AppCommand::Start { .. } => { - let exe_dir = env::current_exe()? + let exe_path = env::current_exe()?; + let exe_dir = exe_path .parent() .context("Failed to resolve path to the current executable.")? .to_owned(); @@ -21,7 +22,7 @@ async fn main() -> anyhow::Result<()> { let main_path = [exe_dir.join("glazewm.exe"), exe_dir.join("../glazewm.exe")] .into_iter() - .find(|path| path.exists()) + .find(|path| path.exists() && *path != exe_path) .and_then(|path| path.to_str().map(ToString::to_string)) .context("Failed to resolve path to the main executable.")?;