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:
parent
749b9f0433
commit
40adfaf810
3 changed files with 17 additions and 6 deletions
|
@ -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?")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue