From 3cfcaf65ad976d896698e7e1973e1f9e7c36016d Mon Sep 17 00:00:00 2001 From: Kingtous Date: Thu, 8 Dec 2022 17:43:46 +0800 Subject: [PATCH] opt: add display server check --- libs/hbb_common/src/platform/linux.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/hbb_common/src/platform/linux.rs b/libs/hbb_common/src/platform/linux.rs index 8c3f2c85c..e50823438 100644 --- a/libs/hbb_common/src/platform/linux.rs +++ b/libs/hbb_common/src/platform/linux.rs @@ -82,9 +82,11 @@ fn get_display_server_of_session(session: &str) -> String { } else { "".to_owned() }; - // loginctl has not given the expected output. try something else. - if let Ok(sestype) = std::env::var("XDG_SESSION_TYPE") { - display_server = sestype; + if display_server.is_empty() { + // loginctl has not given the expected output. try something else. + if let Ok(sestype) = std::env::var("XDG_SESSION_TYPE") { + display_server = sestype; + } } // If the session is not a tty, then just return the type as usual display_server