From f9d0974fc58232101a9d652497bcd67823cd0204 Mon Sep 17 00:00:00 2001 From: sirtemporary <110200481+sirtemporary@users.noreply.github.com> Date: Sat, 30 Jul 2022 15:03:49 -0400 Subject: [PATCH 1/2] Update linux.rs Fix for #921 in mx linux, when started with non-systemd init, loginctl returns null string to stdout (and an error message to stderr). this patch will use XDG_SESSION_TYPE and XDG_SESSION_ID environment variables if the loginctl code fails to determine these. --- libs/hbb_common/src/platform/linux.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libs/hbb_common/src/platform/linux.rs b/libs/hbb_common/src/platform/linux.rs index da79e9e39..81b5825da 100644 --- a/libs/hbb_common/src/platform/linux.rs +++ b/libs/hbb_common/src/platform/linux.rs @@ -43,6 +43,10 @@ fn get_display_server_of_session(session: &str) -> String { display_server } } else { + // loginctl has not given the expected output. try something else. + if let OK(sestype) = std::env::var("XDG_SESSION_TYPE") { + return sestype.to_owned(); + } // If the session is not a tty, then just return the type as usual display_server } @@ -80,6 +84,11 @@ pub fn get_value_of_seat0(i: usize) -> String { } } + // loginctl has not given the expected output. try something else. + if let Ok(sid) = std::env::var("XDG_SESSION_ID") { // could also execute "cat /proc/self/sessionid" + return sid.to_owned(); + } + return "".to_owned(); } From f3f48d3cf4aba582490fd1477ca09ccaf833a59c Mon Sep 17 00:00:00 2001 From: sirtemporary <110200481+sirtemporary@users.noreply.github.com> Date: Sat, 30 Jul 2022 15:19:41 -0400 Subject: [PATCH 2/2] Update linux.rs --- libs/hbb_common/src/platform/linux.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hbb_common/src/platform/linux.rs b/libs/hbb_common/src/platform/linux.rs index 81b5825da..865033204 100644 --- a/libs/hbb_common/src/platform/linux.rs +++ b/libs/hbb_common/src/platform/linux.rs @@ -44,7 +44,7 @@ fn get_display_server_of_session(session: &str) -> String { } } else { // loginctl has not given the expected output. try something else. - if let OK(sestype) = std::env::var("XDG_SESSION_TYPE") { + if let Ok(sestype) = std::env::var("XDG_SESSION_TYPE") { return sestype.to_owned(); } // If the session is not a tty, then just return the type as usual