diff --git a/Cargo.lock b/Cargo.lock index 07ab475..b56012e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1381,7 +1381,7 @@ checksum = "bb20dcc30536a1508e75d47dd0e399bb2fe7354dcf35cda9127f2bf1ed92e30e" [[package]] name = "pop-launcher" -version = "1.0.1" +version = "1.0.2" dependencies = [ "blocking", "const_format", @@ -1404,7 +1404,7 @@ dependencies = [ [[package]] name = "pop-launcher-plugins" -version = "1.0.1" +version = "1.0.2" dependencies = [ "async-pidfd", "fork", @@ -1435,7 +1435,7 @@ dependencies = [ [[package]] name = "pop-launcher-service" -version = "1.0.1" +version = "1.0.2" dependencies = [ "anyhow", "async-io", diff --git a/plugins/src/find/mod.rs b/plugins/src/find/mod.rs index c1f48f5..eb8351b 100644 --- a/plugins/src/find/mod.rs +++ b/plugins/src/find/mod.rs @@ -207,21 +207,29 @@ impl SearchContext { } } -/// Submits the search query to `fdfind`, and returns its stdout pipe. +/// Submits the search query to `fdfind`, and returns its stdout pipe. Falls +/// back to fdfind if it cannot be spawned. async fn query(arg: &str) -> io::Result<(Child, ChildStdout)> { - let mut child = Command::new("fdfind") - .arg("-i") - .arg(arg) - .stdin(Stdio::null()) - .stdout(Stdio::piped()) - .stderr(Stdio::null()) - .spawn()?; + // Closure to spawn the process + let spawn = |cmd: &str| -> io::Result { + Command::new(cmd) + .arg("-i") + .arg(arg) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::null()) + .spawn() + }; - match child.stdout.take() { - Some(stdout) => Ok((child, stdout)), - None => Err(io::Error::new( - io::ErrorKind::BrokenPipe, - "stdout pipe is missing", - )), - } + // Try fdfind first, then fall back to fd + let mut child = match spawn("fdfind") { + Err(why) if why.kind() == io::ErrorKind::NotFound => spawn("fd"), + result => result, + }?; + + child + .stdout + .take() + .map(move |stdout| (child, stdout)) + .ok_or_else(|| io::Error::new(io::ErrorKind::BrokenPipe, "stdout pipe is missing")) }