From 83faf6025b1414597d35224e9dfee5687e1b3d6c Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Fri, 1 Dec 2023 05:11:41 +0530 Subject: [PATCH 1/4] use wayland-data-control arboard feature Signed-off-by: Sahil Yeole --- Cargo.lock | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- 2 files changed, 148 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 642828d4a..950a99e18 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,6 +274,7 @@ dependencies = [ "parking_lot", "thiserror", "winapi 0.3.9", + "wl-clipboard-rs", "x11rb 0.10.1", ] @@ -716,6 +717,12 @@ version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec" +[[package]] +name = "bytecount" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e5f035d16fc623ae5f74981db80a439803888314e3a555fd6f04acd51a3205" + [[package]] name = "bytemuck" version = "1.14.0" @@ -1560,6 +1567,17 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "derive-new" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "syn 1.0.109", +] + [[package]] name = "derive_more" version = "0.99.17" @@ -1742,6 +1760,12 @@ dependencies = [ "strsim 0.10.0", ] +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + [[package]] name = "dtoa" version = "0.4.8" @@ -2015,6 +2039,12 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + [[package]] name = "flate2" version = "1.0.28" @@ -4181,6 +4211,16 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "os_pipe" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" +dependencies = [ + "libc", + "windows-sys 0.48.0", +] + [[package]] name = "osascript" version = "0.3.0" @@ -4344,6 +4384,16 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" +[[package]] +name = "petgraph" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1d3afd2628e69da2be385eb6f2fd57c8ac7977ceeff6dc166ff1657b0e386a9" +dependencies = [ + "fixedbitset", + "indexmap 2.0.2", +] + [[package]] name = "phf" version = "0.7.24" @@ -6425,6 +6475,20 @@ dependencies = [ "windows-sys 0.48.0", ] +[[package]] +name = "tree_magic_mini" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91adfd0607cacf6e4babdb870e9bec4037c1c4b151cfd279ccefc5e0c7feaa6d" +dependencies = [ + "bytecount", + "fnv", + "lazy_static", + "nom", + "once_cell", + "petgraph", +] + [[package]] name = "try-lock" version = "0.2.4" @@ -6762,6 +6826,65 @@ version = "0.2.87" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" +[[package]] +name = "wayland-client" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" +dependencies = [ + "bitflags 1.3.2", + "downcast-rs", + "libc", + "nix 0.24.3", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-commons" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" +dependencies = [ + "nix 0.24.3", + "once_cell", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-protocols" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" +dependencies = [ + "bitflags 1.3.2", + "wayland-client", + "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" +dependencies = [ + "proc-macro2 1.0.69", + "quote 1.0.33", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.29.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" +dependencies = [ + "pkg-config", +] + [[package]] name = "web-sys" version = "0.3.64" @@ -7273,6 +7396,24 @@ dependencies = [ "toml 0.5.11", ] +[[package]] +name = "wl-clipboard-rs" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "981a303dfbb75d659f6612d05a14b2e363c103d24f676a2d44a00d18507a1ad9" +dependencies = [ + "derive-new", + "libc", + "log", + "nix 0.24.3", + "os_pipe", + "tempfile", + "thiserror", + "tree_magic_mini", + "wayland-client", + "wayland-protocols", +] + [[package]] name = "wol-rs" version = "1.0.1" @@ -7380,6 +7521,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "xml-rs" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" + [[package]] name = "zbus" version = "3.14.1" diff --git a/Cargo.toml b/Cargo.toml index cb94b7da1..12c261309 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -94,7 +94,7 @@ sys-locale = "0.3" enigo = { path = "libs/enigo", features = [ "with_serde" ] } clipboard = { path = "libs/clipboard" } ctrlc = "3.2" -arboard = "3.2" +arboard = { version = "3.2", features = ["wayland-data-control"] } system_shutdown = "4.0" [target.'cfg(target_os = "windows")'.dependencies] From 7ac49287dfadba788520e861f591965fdabf00e2 Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Fri, 1 Dec 2023 05:13:03 +0530 Subject: [PATCH 2/4] set WAYLAND_DISPLAY env Signed-off-by: Sahil Yeole --- src/platform/linux.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 5b9d36c9e..58e9a9e0f 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -213,6 +213,9 @@ fn try_start_server_(desktop: Option<&Desktop>) -> ResultType> { if !desktop.xauth.is_empty() { envs.push(("XAUTHORITY", desktop.xauth.clone())); } + if !desktop.wl_display.is_empty() { + envs.push(("WAYLAND_DISPLAY", desktop.wl_display.clone())); + } run_as_user( vec!["--server"], Some((desktop.uid.clone(), desktop.username.clone())), @@ -936,6 +939,7 @@ mod desktop { pub display: String, pub xauth: String, pub is_rustdesk_subprocess: bool, + pub wl_display: String, } impl Desktop { @@ -966,6 +970,7 @@ mod desktop { for proc in display_proc { self.display = get_env("DISPLAY", &self.uid, proc); self.xauth = get_env("XAUTHORITY", &self.uid, proc); + self.wl_display = get_env("WAYLAND_DISPLAY", &self.uid, proc); if !self.display.is_empty() && !self.xauth.is_empty() { break; } From 0f307e7ca2aa8e485e5c83457cc71ead1bbd63a2 Mon Sep 17 00:00:00 2001 From: Sahil Yeole Date: Fri, 1 Dec 2023 05:14:09 +0530 Subject: [PATCH 3/4] preserve sudo env; required for WAYLAND_DISPLAY Signed-off-by: Sahil Yeole --- src/platform/linux.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 58e9a9e0f..db37d573a 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -591,10 +591,8 @@ where let xdg = &format!("XDG_RUNTIME_DIR=/run/user/{}", uid) as &str; let mut args = vec![xdg, "-u", &username, cmd.to_str().unwrap_or("")]; args.append(&mut arg.clone()); - // -E required for opensuse - if is_opensuse() { + // -E is required to preserve env args.insert(0, "-E"); - } let task = Command::new("sudo").envs(envs).args(args).spawn()?; Ok(Some(task)) From b662090d6478b79bbb57af2abf76a95f483b1742 Mon Sep 17 00:00:00 2001 From: Sahil Yeole <73148455+sahilyeole@users.noreply.github.com> Date: Fri, 1 Dec 2023 18:23:23 +0530 Subject: [PATCH 4/4] update Cargo.lock for wayland clipboard --- Cargo.lock | 151 +++++++++++++++++++++++++---------------------------- 1 file changed, 72 insertions(+), 79 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 950a99e18..db791efe7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -260,9 +260,9 @@ dependencies = [ [[package]] name = "arboard" -version = "3.2.1" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac57f2b058a76363e357c056e4f74f1945bf734d37b8b3ef49066c4787dde0fc" +checksum = "aafb29b107435aa276664c1db8954ac27a6e105cdad3c88287a199eb0e313c08" dependencies = [ "clipboard-win", "core-graphics 0.22.3", @@ -275,7 +275,7 @@ dependencies = [ "thiserror", "winapi 0.3.9", "wl-clipboard-rs", - "x11rb 0.10.1", + "x11rb", ] [[package]] @@ -965,7 +965,7 @@ dependencies = [ "thiserror", "utf16string", "x11-clipboard", - "x11rb 0.12.0", + "x11rb", ] [[package]] @@ -1696,6 +1696,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" +[[package]] +name = "dlib" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "330c60081dcc4c72131f8eb70510f1ac07223e5d4163db481a04a0befcffa412" +dependencies = [ + "libloading 0.8.1", +] + [[package]] name = "dlopen" version = "0.1.8" @@ -2420,16 +2429,6 @@ dependencies = [ "version_check", ] -[[package]] -name = "gethostname" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1ebd34e35c46e00bb73e81363248d627782724609fe1b6396f553f68fe3862e" -dependencies = [ - "libc", - "winapi 0.3.9", -] - [[package]] name = "gethostname" version = "0.3.0" @@ -3869,7 +3868,6 @@ dependencies = [ "bitflags 1.3.2", "cfg-if 1.0.0", "libc", - "memoffset 0.6.5", ] [[package]] @@ -3882,6 +3880,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "memoffset 0.7.1", + "pin-utils", ] [[package]] @@ -5322,7 +5321,7 @@ dependencies = [ "winres", "wol-rs", "x11-clipboard", - "x11rb 0.12.0", + "x11rb", "zip", ] @@ -5499,6 +5498,12 @@ dependencies = [ "objc-foundation", ] +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + [[package]] name = "scopeguard" version = "1.2.0" @@ -6827,61 +6832,75 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ca6ad05a4870b2bf5fe995117d3728437bd27d7cd5f06f13c17443ef369775a1" [[package]] -name = "wayland-client" -version = "0.29.5" +name = "wayland-backend" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f3b068c05a039c9f755f881dc50f01732214f5685e379829759088967c46715" +checksum = "19152ddd73f45f024ed4534d9ca2594e0ef252c1847695255dae47f34df9fbe4" dependencies = [ - "bitflags 1.3.2", + "cc", "downcast-rs", - "libc", - "nix 0.24.3", - "wayland-commons", - "wayland-scanner", - "wayland-sys", -] - -[[package]] -name = "wayland-commons" -version = "0.29.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8691f134d584a33a6606d9d717b95c4fa20065605f798a3f350d78dced02a902" -dependencies = [ - "nix 0.24.3", - "once_cell", + "nix 0.26.4", + "scoped-tls", "smallvec", "wayland-sys", ] [[package]] -name = "wayland-protocols" -version = "0.29.5" +name = "wayland-client" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b950621f9354b322ee817a23474e479b34be96c2e909c14f7bc0100e9a970bc6" +checksum = "1ca7d52347346f5473bf2f56705f360e8440873052e575e55890c4fa57843ed3" dependencies = [ - "bitflags 1.3.2", + "bitflags 2.4.1", + "nix 0.26.4", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols" +version = "0.31.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e253d7107ba913923dc253967f35e8561a3c65f914543e46843c88ddd729e21c" +dependencies = [ + "bitflags 2.4.1", + "wayland-backend", "wayland-client", - "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad1f61b76b6c2d8742e10f9ba5c3737f6530b4c243132c2a2ccc8aa96fe25cd6" +dependencies = [ + "bitflags 2.4.1", + "wayland-backend", + "wayland-client", + "wayland-protocols", "wayland-scanner", ] [[package]] name = "wayland-scanner" -version = "0.29.5" +version = "0.31.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f4303d8fa22ab852f789e75a967f0a2cdc430a607751c0499bada3e451cbd53" +checksum = "fb8e28403665c9f9513202b7e1ed71ec56fde5c107816843fb14057910b2c09c" dependencies = [ "proc-macro2 1.0.69", + "quick-xml", "quote 1.0.33", - "xml-rs", ] [[package]] name = "wayland-sys" -version = "0.29.5" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be12ce1a3c39ec7dba25594b97b42cb3195d54953ddb9d3d95a7c3902bc6e9d4" +checksum = "15a0c8eaff5216d07f226cb7a549159267f3467b289d9a2e52fd3ef5aae2b7af" dependencies = [ + "dlib", + "log", "pkg-config", ] @@ -7398,20 +7417,22 @@ dependencies = [ [[package]] name = "wl-clipboard-rs" -version = "0.7.0" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "981a303dfbb75d659f6612d05a14b2e363c103d24f676a2d44a00d18507a1ad9" +checksum = "57af79e973eadf08627115c73847392e6b766856ab8e3844a59245354b23d2fa" dependencies = [ "derive-new", "libc", "log", - "nix 0.24.3", + "nix 0.26.4", "os_pipe", "tempfile", "thiserror", "tree_magic_mini", + "wayland-backend", "wayland-client", "wayland-protocols", + "wayland-protocols-wlr", ] [[package]] @@ -7453,7 +7474,7 @@ name = "x11-clipboard" version = "0.8.1" source = "git+https://github.com/clslaid/x11-clipboard?branch=feat/store-batch#5fc2e73bc01ada3681159b34cf3ea8f0d14cd904" dependencies = [ - "x11rb 0.12.0", + "x11rb", ] [[package]] @@ -7467,39 +7488,17 @@ dependencies = [ "pkg-config", ] -[[package]] -name = "x11rb" -version = "0.10.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "592b4883219f345e712b3209c62654ebda0bb50887f330cbd018d0f654bfd507" -dependencies = [ - "gethostname 0.2.3", - "nix 0.24.3", - "winapi 0.3.9", - "winapi-wsapoll", - "x11rb-protocol 0.10.0", -] - [[package]] name = "x11rb" version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b1641b26d4dec61337c35a1b1aaf9e3cba8f46f0b43636c609ab0291a648040a" dependencies = [ - "gethostname 0.3.0", + "gethostname", "nix 0.26.4", "winapi 0.3.9", "winapi-wsapoll", - "x11rb-protocol 0.12.0", -] - -[[package]] -name = "x11rb-protocol" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56b245751c0ac9db0e006dc812031482784e434630205a93c73cfefcaabeac67" -dependencies = [ - "nix 0.24.3", + "x11rb-protocol", ] [[package]] @@ -7521,12 +7520,6 @@ dependencies = [ "winapi 0.3.9", ] -[[package]] -name = "xml-rs" -version = "0.8.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcb9cbac069e033553e8bb871be2fbdffcab578eb25bd0f7c508cedc6dcd75a" - [[package]] name = "zbus" version = "3.14.1"