From feccc29fd139437c6136c17761ca8dff88fe6698 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Sun, 20 Jul 2025 16:21:31 +0100 Subject: [PATCH] fix: regression caused by #1089 This resolves an issue caused by a previous fix which broke launching applications with the `launcher` and `menu` modules --- src/desktop_file.rs | 26 +++++++++++++++++++------- src/modules/menu/ui.rs | 4 +--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/desktop_file.rs b/src/desktop_file.rs index d194098..f6e9d61 100644 --- a/src/desktop_file.rs +++ b/src/desktop_file.rs @@ -332,7 +332,7 @@ pub async fn open_program(file_name: &str, launch_command: &str) { let launch_command_parts: Vec<&str> = expanded.split_whitespace().collect(); debug!("running {launch_command_parts:?}"); - if let Err(err) = Command::new(launch_command_parts[0]) + let exit_status = match Command::new(launch_command_parts[0]) .args(&launch_command_parts[1..]) .stdin(Stdio::null()) .stdout(Stdio::null()) @@ -340,12 +340,24 @@ pub async fn open_program(file_name: &str, launch_command: &str) { .kill_on_drop(true) .spawn() { - error!( - "{:?}", - Report::new(err) - .wrap_err("Failed to run launch command.") - .suggestion("Perhaps the desktop file is invalid or orphaned?") - ); + Ok(mut child) => Some(child.wait().await), + Err(err) => { + error!( + "{:?}", + Report::new(err) + .wrap_err("Failed to run launch command.") + .suggestion("Perhaps the desktop file is invalid or orphaned?") + ); + None + } + }; + + match exit_status { + Some(Ok(exit_status)) if !exit_status.success() => { + error!("received non-success exit status running {launch_command_parts:?}") + } + Some(Err(err)) => error!("{err:?}"), + _ => {} } } diff --git a/src/modules/menu/ui.rs b/src/modules/menu/ui.rs index 7f73871..ce47a7c 100644 --- a/src/modules/menu/ui.rs +++ b/src/modules/menu/ui.rs @@ -104,9 +104,7 @@ where let file_name = file_name.clone(); let command = command.clone(); - glib::spawn_future_local(async move { - open_program(&file_name, &command).await - }); + spawn(async move { open_program(&file_name, &command).await }); sub_menu.hide(); tx.send_spawn(ModuleUpdateEvent::ClosePopup);