mirror of
https://github.com/wez/wezterm.git
synced 2024-11-22 04:56:12 +03:00
remove open dependency
refs: https://github.com/wez/wezterm/issues/3288
This commit is contained in:
parent
f5ba73a1a2
commit
060d0f1ed4
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -3353,15 +3353,6 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5"
|
||||
|
||||
[[package]]
|
||||
name = "open"
|
||||
version = "4.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd61e3bf9d78956c72ee864bba52431f7f43994b21a17e9e72596a81bd61075b"
|
||||
dependencies = [
|
||||
"pathdiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "openssl"
|
||||
version = "0.10.38"
|
||||
@ -3485,12 +3476,6 @@ dependencies = [
|
||||
"windows-sys 0.45.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pathdiff"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
|
||||
|
||||
[[package]]
|
||||
name = "pem"
|
||||
version = "1.1.1"
|
||||
@ -6106,7 +6091,6 @@ dependencies = [
|
||||
name = "wezterm-open-url"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"open",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -6,5 +6,4 @@ edition = "2021"
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
open = "4.0"
|
||||
winapi = {version="0.3", features=["shellapi"]}
|
||||
|
@ -1,14 +1,57 @@
|
||||
// Portions of this file are derived from code that is
|
||||
// Copyright © 2015 Sebastian Thiel
|
||||
// <https://github.com/Byron/open-rs>
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn open_url(url: &str) {
|
||||
let url = url.to_string();
|
||||
std::thread::spawn(move || {
|
||||
let _ = open::that(&url);
|
||||
#[cfg(target_os = "macos")]
|
||||
let candidates: &[&[&str]] = &[&["/usr/bin/open", &url]];
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let candidates: &[&[&str]] = &[
|
||||
&["xdg-open", &url],
|
||||
&["gio", "open", &url] as &[_],
|
||||
&["gnome-open", &url],
|
||||
&["kde-open", &url],
|
||||
&["wslview", &url],
|
||||
];
|
||||
|
||||
for candidate in candidates {
|
||||
let mut cmd = std::process::Command::new(candidate[0]);
|
||||
cmd.args(&candidate[1..]);
|
||||
|
||||
if let Ok(status) = cmd.status() {
|
||||
if status.success() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
pub fn open_with(url: &str, app: &str) {
|
||||
open::with_in_background(url, app);
|
||||
let url = url.to_string();
|
||||
let app = app.to_string();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
#[cfg(target_os = "macos")]
|
||||
let args: &[&str] = &["/usr/bin/open", "-a", &app, &url];
|
||||
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
let args: &[&str] = &[&app, &url];
|
||||
|
||||
let mut cmd = std::process::Command::new(args[0]);
|
||||
cmd.args(&args[1..]);
|
||||
|
||||
if let Ok(status) = cmd.status() {
|
||||
if status.success() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
|
Loading…
Reference in New Issue
Block a user