1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-09-15 19:26:58 +02:00

fix: opening programs via launcher and menu leaving zombie processes

Fixes #1020
This commit is contained in:
Jake Stanger 2025-07-14 21:42:11 +01:00
commit 40adfaf810
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
3 changed files with 17 additions and 6 deletions

View file

@ -3,9 +3,10 @@ use color_eyre::{Help, Report, Result};
use std::collections::HashMap;
use std::env;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::process::Stdio;
use std::sync::Arc;
use tokio::io::{AsyncBufReadExt, BufReader};
use tokio::process::Command;
use tokio::sync::Mutex;
use tracing::{debug, error};
use walkdir::{DirEntry, WalkDir};
@ -325,20 +326,24 @@ fn files(dir: &Path) -> Vec<PathBuf> {
}
/// Starts a `.desktop` file with the provided formatted command.
pub fn open_program(file_name: &str, str: &str) {
let expanded = str.replace("{app_name}", file_name);
pub async fn open_program(file_name: &str, launch_command: &str) {
let expanded = launch_command.replace("{app_name}", file_name);
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])
.args(&launch_command_parts[1..])
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.kill_on_drop(true)
.spawn()
{
error!(
"{:?}",
Report::new(err)
.wrap_err("Failed to run launch command.")
.suggestion("Perhaps the applications file is invalid?")
.suggestion("Perhaps the desktop file is invalid or orphaned?")
);
}
}