From 4c39faffbea7efdce09e34bf89503ebfe0737a67 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 18 Feb 2019 22:57:40 -0800 Subject: [PATCH] use the `open` crate for url clicking --- Cargo.toml | 1 + get-deps | 1 + src/gliumwindows.rs | 9 +++------ src/main.rs | 1 + src/xwindows/xwin.rs | 7 ++----- 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 1f1b996f2..645cc129e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,6 +23,7 @@ rusttype = "0.7" clipboard = "0.5" unicode-normalization = "~0.1" freetype = "~0.4" +open = "1.2" [target.'cfg(unix)'.dependencies] harfbuzz-sys = "~0.2" diff --git a/get-deps b/get-deps index a81fb06bb..7cda92cad 100755 --- a/get-deps +++ b/get-deps @@ -28,6 +28,7 @@ case `lsb_release -ds` in libfreetype6-dev \ libegl1-mesa-dev \ libharfbuzz-dev \ + xdg-utils \ ragel ;; *) diff --git a/src/gliumwindows.rs b/src/gliumwindows.rs index 4127c5fc3..386c991b3 100644 --- a/src/gliumwindows.rs +++ b/src/gliumwindows.rs @@ -1,7 +1,7 @@ //! Generic system dependent windows via glium+glutin +use super::Child; use super::MasterPty; -use super::{Child, Command}; use clipboard::{ClipboardContext, ClipboardProvider}; use config::Config; use failure::Error; @@ -67,12 +67,9 @@ impl term::TerminalHost for Host { &mut self.pty } fn click_link(&mut self, link: &Rc) { - // TODO: make this configurable - let mut cmd = Command::new("xdg-open"); - cmd.arg(link.uri()); - match cmd.spawn() { + match open::that(link.uri()) { Ok(_) => {} - Err(err) => eprintln!("failed to spawn xdg-open {}: {:?}", link.uri(), err), + Err(err) => eprintln!("failed to open {}: {:?}", link.uri(), err), } } diff --git a/src/main.rs b/src/main.rs index ba18bb6a9..d3c344049 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,7 @@ extern crate serde; extern crate serde_derive; extern crate clipboard; extern crate font_loader; +extern crate open; extern crate rusttype; extern crate term; extern crate termwiz; diff --git a/src/xwindows/xwin.rs b/src/xwindows/xwin.rs index f70f7c5c0..ddafd4640 100644 --- a/src/xwindows/xwin.rs +++ b/src/xwindows/xwin.rs @@ -121,12 +121,9 @@ impl<'a> term::TerminalHost for TabHost<'a> { } fn click_link(&mut self, link: &Rc) { - // TODO: make this configurable - let mut cmd = Command::new("xdg-open"); - cmd.arg(&link.uri()); - match cmd.spawn() { + match open::that(link.uri()) { Ok(_) => {} - Err(err) => eprintln!("failed to spawn xdg-open {}: {:?}", link.uri(), err), + Err(err) => eprintln!("failed to open {}: {:?}", link.uri(), err), } }