mirror of
https://github.com/kittywitch/fzfdapter.git
synced 2026-02-09 06:39:19 -08:00
feat: fork instead of just spawning command
This commit is contained in:
parent
ce503517bb
commit
17aab3c2d7
4 changed files with 39 additions and 25 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -164,6 +164,15 @@ version = "0.1.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52051878f80a721bb68ebfbc930e07b65ba72f2da88968ea5c06fd6ca3d3a127"
|
||||
|
||||
[[package]]
|
||||
name = "fork"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed479091df6b84e9670acc5fa0339f1d2c6b7459e432455a26c75848048ae14d"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "freedesktop-desktop-entry"
|
||||
version = "0.7.19"
|
||||
|
|
@ -185,6 +194,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
"fork",
|
||||
"freedesktop-desktop-entry",
|
||||
"indexmap",
|
||||
"is_executable",
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ edition = "2024"
|
|||
[dependencies]
|
||||
anyhow = "1.0.100"
|
||||
clap = { version = "4.5.50", features = ["derive"] }
|
||||
fork = "0.3.1"
|
||||
freedesktop-desktop-entry = "0.7.19"
|
||||
indexmap = { version = "2.12.0", features = ["serde"] }
|
||||
is_executable = "1.0.5"
|
||||
|
|
|
|||
|
|
@ -8,9 +8,10 @@ rustPlatform.buildRustPackage (_finalAttrs: {
|
|||
|
||||
src = ./.;
|
||||
|
||||
cargoHash = "sha256-aaLgttzAlHJciCDn9vQ2bHPoNc6lcXQa4GIJQPvUgyw=";
|
||||
cargoHash = "sha256-gwaH/Q9VN1i3JLruj6aRBhInWy+qHV+g32wSKY++msw=";
|
||||
|
||||
meta = {
|
||||
mainProgram = "fzfdapter";
|
||||
description = "fzfdapter, a fuzzel/wofi/rofi... thing for your terminal";
|
||||
homepage = "https://github.com/kittywitch/fzfdapter";
|
||||
license = lib.licenses.gpl3;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,10 @@
|
|||
use {
|
||||
crate::config::AdapterConfig,
|
||||
anyhow::anyhow,
|
||||
std::{
|
||||
crate::config::AdapterConfig, anyhow::anyhow, fork::{daemon, Fork}, std::{
|
||||
mem,
|
||||
path::Path,
|
||||
process::{Command, Stdio},
|
||||
sync::Arc,
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
|
|
@ -18,6 +16,7 @@ pub(crate) enum WhatDo {
|
|||
|
||||
pub(crate) fn handle_xdg(exec: Vec<String>) -> anyhow::Result<()> {
|
||||
let args = exec.get(1..).unwrap_or_default();
|
||||
if let Ok(Fork::Child) = daemon(false, false) {
|
||||
let exec_run = Command::new(exec.first().ok_or(anyhow!(
|
||||
"Command not provided within the XDG desktop file correctly?"
|
||||
))?)
|
||||
|
|
@ -27,6 +26,7 @@ pub(crate) fn handle_xdg(exec: Vec<String>) -> anyhow::Result<()> {
|
|||
.stderr(Stdio::null())
|
||||
.spawn()?;
|
||||
mem::forget(exec_run);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -34,6 +34,7 @@ pub(crate) fn handle_terminal(config: &AdapterConfig, args: &[&str]) -> anyhow::
|
|||
let mut in_args = args.iter().map(|x| x.to_string()).collect();
|
||||
let mut term_args = config.terminal_args();
|
||||
term_args.append(&mut in_args);
|
||||
if let Ok(Fork::Child) = daemon(false, false) {
|
||||
let term_run = Command::new(
|
||||
config
|
||||
.terminal_bin()
|
||||
|
|
@ -45,5 +46,6 @@ pub(crate) fn handle_terminal(config: &AdapterConfig, args: &[&str]) -> anyhow::
|
|||
.stderr(Stdio::null())
|
||||
.spawn()?;
|
||||
mem::forget(term_run);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue