diff --git a/Cargo.lock b/Cargo.lock index c631c99..e82cba8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -44,7 +44,7 @@ version = "2.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d76e1fe0171b6d0857afca5671db12a44e71e80823db13ab39f776fb09ad079" dependencies = [ - "clipboard-win 4.4.1", + "clipboard-win", "core-graphics", "image", "log", @@ -328,40 +328,6 @@ dependencies = [ "syn", ] -[[package]] -name = "clipboard" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a904646c0340239dcf7c51677b33928bf24fdf424b79a57909c0109075b2e7" -dependencies = [ - "clipboard-win 2.2.0", - "objc", - "objc-foundation", - "objc_id", - "x11-clipboard", -] - -[[package]] -name = "clipboard-ext" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac0b9a9fdf4e6100bfcdc6587c9c26a6a1d1d8247e74684c18a113d635d3dc78" -dependencies = [ - "clipboard", - "libc", - "which", - "x11-clipboard", -] - -[[package]] -name = "clipboard-win" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3a093d6fed558e5fe24c3dfc85a68bb68f1c824f440d3ba5aca189e2998786b" -dependencies = [ - "winapi", -] - [[package]] name = "clipboard-win" version = "4.4.1" @@ -588,15 +554,6 @@ version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71" -[[package]] -name = "failure" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" -dependencies = [ - "backtrace", -] - [[package]] name = "fastrand" version = "1.7.0" @@ -901,7 +858,6 @@ dependencies = [ "chrono", "clap", "clap_complete", - "clipboard-ext", "colored", "dirs 4.0.0", "log", @@ -2129,16 +2085,6 @@ dependencies = [ "cc", ] -[[package]] -name = "which" -version = "3.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" -dependencies = [ - "failure", - "libc", -] - [[package]] name = "winapi" version = "0.3.9" @@ -2235,15 +2181,6 @@ dependencies = [ "xml-rs", ] -[[package]] -name = "x11-clipboard" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89bd49c06c9eb5d98e6ba6536cf64ac9f7ee3a009b2f53996d405b3944f6bcea" -dependencies = [ - "xcb", -] - [[package]] name = "x11rb" version = "0.8.1" @@ -2256,16 +2193,6 @@ dependencies = [ "winapi-wsapoll", ] -[[package]] -name = "xcb" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e917a3f24142e9ff8be2414e36c649d47d6cc2ba81f16201cdef96e533e02de" -dependencies = [ - "libc", - "log", -] - [[package]] name = "xml-rs" version = "0.8.4" diff --git a/Cargo.toml b/Cargo.toml index 9736597..0c19197 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,9 +33,6 @@ better-panic = "0.3.0" validator = "0.14.0" colored = "2.0.0" -[target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten"))))'.dependencies] -clipboard-ext = "0.2.0" - [target.'cfg(not(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten")))))'.dependencies] arboard = "2.0.1" diff --git a/src/cli/clipboard.rs b/src/cli/clipboard.rs index f756edc..5bd3a70 100644 --- a/src/cli/clipboard.rs +++ b/src/cli/clipboard.rs @@ -1,21 +1,19 @@ -#[cfg(all( - unix, - not(any(target_os = "macos", target_os = "android", target_os = "emscripten")) -))] -use clipboard_ext::prelude::*; -#[cfg(all( - unix, - not(any(target_os = "macos", target_os = "android", target_os = "emscripten")) -))] -use clipboard_ext::x11_fork::ClipboardContext; - #[cfg(all( unix, not(any(target_os = "macos", target_os = "android", target_os = "emscripten")) ))] pub fn set_clipboard(content: String) { - let mut ctx = ClipboardContext::new().expect("init clipboard"); - ctx.set_contents(content).expect("set clipboard"); + use std::{process::{Command, Stdio}, io::Write}; + + let mut child = Command::new("xsel") + .arg("--input") + .arg("--clipboard") + .stdin(Stdio::piped()) + .spawn() + .expect("execute command xsel"); + + child.stdin.as_mut().unwrap().write_all(content.as_bytes()).expect("execute command"); + child.wait_with_output().unwrap(); } #[cfg(not(all(