Detach command execution from power-menu app

This commit is contained in:
Candifloss 2026-01-12 13:25:00 +05:30
parent 25eab25511
commit 07c2793f17

View File

@ -30,6 +30,16 @@ fn spawn_command(cmd: &str) {
let _ = Command::new("sh").arg("-c").arg(cmd).spawn(); let _ = Command::new("sh").arg("-c").arg(cmd).spawn();
} }
fn spawn_detached(cmd: &str) {
let _ = Command::new("sh")
.arg("-c")
.arg(cmd)
.stdin(std::process::Stdio::null())
.stdout(std::process::Stdio::null())
.stderr(std::process::Stdio::null())
.spawn();
}
fn build_options_model( fn build_options_model(
opts: &[crate::config::MenuOption], opts: &[crate::config::MenuOption],
) -> (ModelRc<MenuOption>, HashMap<String, String>) { ) -> (ModelRc<MenuOption>, HashMap<String, String>) {
@ -86,7 +96,10 @@ pub fn run_power_menu(cfg: ResolvedConfig) -> Result<(), Box<dyn std::error::Err
move |id: SharedString| { move |id: SharedString| {
if let Some(cmd) = command_map.get(id.as_str()) { if let Some(cmd) = command_map.get(id.as_str()) {
spawn_command(cmd); spawn_detached(cmd);
// Exit immediately
slint::quit_event_loop();
} }
} }
}); });