From 90bc6348e00e2e42cc0f7ed3eb7746d6e749749e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= Date: Sun, 18 Apr 2021 09:31:02 +0200 Subject: [PATCH 1/2] Add support for gio open on Linux --- README.md | 2 +- src/lib.rs | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 97959de..ee0a0c9 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ $ open # Windows $ start # Linux -$ open || xdg-open || gnome-open || kde-open +$ xdg-open || gio open || gnome-open || kde-open || wslview ``` # Usage diff --git a/src/lib.rs b/src/lib.rs index d4d0ba6..fb148cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -252,18 +252,28 @@ mod unix { use which::which; pub fn that + Sized>(path: T) -> Result { - ["xdg-open", "gnome-open", "kde-open", "wslview"] // Open handlers + ["xdg-open", "gio", "gnome-open", "kde-open", "wslview"] // Open handlers .iter() .find(|it| which(it).is_ok()) // find the first handler that exists .ok_or(Error::from_raw_os_error(0)) // If not found, return err .and_then(|program| { // If found run the handler - Command::new(program) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .arg(path.as_ref()) - .spawn()? - .wait() + if program.to_string() == "gio" { + Command::new(program) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .arg("open") + .arg(path.as_ref()) + .spawn()? + .wait() + } else { + Command::new(program) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .arg(path.as_ref()) + .spawn()? + .wait() + } }) } From 6a1766a602fa3354827b06d7b5dbf8f694b86690 Mon Sep 17 00:00:00 2001 From: Sebastian Thiel Date: Sun, 18 Apr 2021 17:34:44 +0800 Subject: [PATCH 2/2] Remove unnecessary allocation --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index fb148cc..1367e85 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -258,7 +258,7 @@ mod unix { .ok_or(Error::from_raw_os_error(0)) // If not found, return err .and_then(|program| { // If found run the handler - if program.to_string() == "gio" { + if *program == "gio" { Command::new(program) .stdout(Stdio::null()) .stderr(Stdio::null())