diff --git a/.changes/shell-xdgopen.md b/.changes/shell-xdgopen.md new file mode 100644 index 00000000..ddd0fc67 --- /dev/null +++ b/.changes/shell-xdgopen.md @@ -0,0 +1,5 @@ +--- +shell: patch +--- + +shell.open will now try to execute `/usr/bin/xdg-open` before using `xdg-open` from `PATH`. diff --git a/plugins/opener/src/open.rs b/plugins/opener/src/open.rs index a3d46c50..d3bd2919 100644 --- a/plugins/opener/src/open.rs +++ b/plugins/opener/src/open.rs @@ -9,6 +9,13 @@ use std::{ffi::OsStr, path::Path}; pub(crate) fn open, S: AsRef>(path: P, with: Option) -> crate::Result<()> { match with { Some(program) => ::open::with_detached(path, program.as_ref()), + #[cfg(target_os = "linux")] + None => { + // ref https://github.com/tauri-apps/tauri/issues/10617 + ::open::with_detached(&path, "/usr/bin/xdg-open") + .or_else(|_| ::open::that_detached(path)) + } + #[cfg(not(target_os = "linux"))] None => ::open::that_detached(path), } .map_err(Into::into) diff --git a/plugins/shell/src/scope.rs b/plugins/shell/src/scope.rs index 35fdeaff..c1196f44 100644 --- a/plugins/shell/src/scope.rs +++ b/plugins/shell/src/scope.rs @@ -225,6 +225,13 @@ impl OpenScope { // the `open` dependency. This behavior should be re-confirmed during upgrades of `open`. match with.map(Program::name) { Some(program) => ::open::with_detached(path, program), + #[cfg(target_os = "linux")] + None => { + // ref https://github.com/tauri-apps/tauri/issues/10617 + ::open::with_detached(path, "/usr/bin/xdg-open") + .or_else(|_| ::open::that_detached(path)) + } + #[cfg(not(target_os = "linux"))] None => ::open::that_detached(path), } .map_err(Into::into)