An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.
Rust androidanydeskdartflatpakflutterflutter-appsioslinuxmacosp2prdpremote-controlremote-desktoprustrust-langteamviewervncwaylandwindows
fix, wayland --server, display env, better way to find the envs
fufesoub7a4c0664b95
diff --git a/src/platform/linux.rs b/src/platform/linux.rsindex 8ab7693b0..3a140051c 100644--- a/src/platform/linux.rs+++ b/src/platform/linux.rs@@ -667,17 +667,6 @@ pub fn is_installed() -> bool {}}-pub(super) fn get_env_tries(name: &str, uid: &str, process: &str, n: usize) -> String {- for _ in 0..n {- let x = get_env(name, uid, process);- if !x.is_empty() {- return x;- }- sleep_millis(300);- }- "".to_owned()-}-#[inline]fn get_env(name: &str, uid: &str, process: &str) -> String {let cmd = format!("ps -u {} -f | grep -E '{}' | grep -v 'grep' | tail -1 | awk '{{print $2}}' | xargs -I__ cat /proc/__/environ 2>/dev/null | tr '\\0' '\\n' | grep '^{}=' | tail -1 | sed 's/{}=//g'", uid, process, name, name);@@ -917,6 +906,7 @@ mod desktop {pub const XFCE4_PANEL: &str = "xfce4-panel";pub const SDDM_GREETER: &str = "sddm-greeter";+ const IBUS_DAEMON: &str = "ibus-daemon";const PLASMA_KDED5: &str = "kded5";const GNOME_GOA_DAEMON: &str = "goa-daemon";const RUSTDESK_TRAY: &str = "rustdesk +--tray";@@ -948,33 +938,36 @@ mod desktop {self.sid.is_empty() || self.is_rustdesk_subprocess}- fn get_display_wayland(&mut self) {- let display_proc = vec![PLASMA_KDED5, GNOME_GOA_DAEMON, RUSTDESK_TRAY];- for proc in display_proc {- self.display = get_env("DISPLAY", &self.uid, proc);- if !self.display.is_empty() {- break;- }- }- }-- fn get_xauth_wayland(&mut self) {- let display_proc = vec![PLASMA_KDED5, GNOME_GOA_DAEMON, RUSTDESK_TRAY];- for proc in display_proc {- self.xauth = get_env("XAUTHORITY", &self.uid, proc);- if !self.xauth.is_empty() {- break;+ fn get_display_xauth_wayland(&mut self) {+ for _ in 0..5 {+ let display_proc = vec![IBUS_DAEMON, GNOME_GOA_DAEMON, PLASMA_KDED5, RUSTDESK_TRAY];+ for proc in display_proc {+ self.display = get_env("DISPLAY", &self.uid, proc);+ self.xauth = get_env("XAUTHORITY", &self.uid, proc);+ if !self.display.is_empty() && !self.xauth.is_empty() {+ break;+ }}+ sleep_millis(300);}}fn get_display_x11(&mut self) {- let display_envs = vec![PLASMA_KDED5, GNOME_GOA_DAEMON, XFCE4_PANEL, SDDM_GREETER];- for display_env in display_envs {- self.display = get_env_tries("DISPLAY", &self.uid, display_env, 10);- if !self.display.is_empty() {- break;+ for _ in 0..10 {+ let display_proc = vec![+ IBUS_DAEMON,+ GNOME_GOA_DAEMON,+ PLASMA_KDED5,+ XFCE4_PANEL,+ SDDM_GREETER,+ ];+ for proc in display_proc {+ self.display = get_env("DISPLAY", &self.uid, proc);+ if !self.display.is_empty() {+ break;+ }}+ sleep_millis(300);}if self.display.is_empty() {@@ -1032,12 +1025,21 @@ mod desktop {fn get_xauth_x11(&mut self) {// try by direct access to window manager process by name- let display_envs = vec![PLASMA_KDED5, GNOME_GOA_DAEMON, XFCE4_PANEL, SDDM_GREETER];- for diplay_env in display_envs {- self.xauth = get_env_tries("XAUTHORITY", &self.uid, diplay_env, 10);- if !self.xauth.is_empty() {- break;+ for _ in 0..10 {+ let display_proc = vec![+ IBUS_DAEMON,+ GNOME_GOA_DAEMON,+ PLASMA_KDED5,+ XFCE4_PANEL,+ SDDM_GREETER,+ ];+ for proc in display_proc {+ self.xauth = get_env("XAUTHORITY", &self.uid, proc);+ if !self.xauth.is_empty() {+ break;+ }}+ sleep_millis(300);}// get from Xorg process, parameter and environment@@ -1124,6 +1126,11 @@ mod desktop {pub fn refresh(&mut self) {if !self.sid.is_empty() && is_active_and_seat0(&self.sid) {+ // Wayland display and xauth may not be available in a short time after login.+ if self.is_wayland() && !self.is_login_wayland() {+ self.get_display_xauth_wayland();+ self.is_rustdesk_subprocess = false;+ }return;}@@ -1146,8 +1153,7 @@ mod desktop {}if self.is_wayland() {- self.get_display_wayland();- self.get_xauth_wayland();+ self.get_display_xauth_wayland();self.is_rustdesk_subprocess = false;} else {self.get_display_x11();