From 514ef6ac0838daa348723a71ffb25bd7aec24070 Mon Sep 17 00:00:00 2001 From: Tom Yan Date: Sat, 19 Apr 2025 01:09:53 +0800 Subject: [PATCH 1/2] Ignore unspecified type session(s) when look through all active sessions With modern systemd versions, there is a manager class session, which is of type "unspecified", for each logged-in / lingering user. Such session should be ignored when attempt to find an appropriate session from all (non-seated) sessions, otherwise it will prevent XDG_SESSION_TYPE (and its "x11" fallback) from being leveraged. --- src/platform/linux.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 60c8714..622685b 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -175,7 +175,7 @@ fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec Date: Sat, 19 Apr 2025 01:32:41 +0800 Subject: [PATCH 2/2] Ignore the session type when started as a user unit If a user for reasons start the program as user unit (instead of as a system unit or in a session), /proc/self/sessionid may result in the inferred session type being "unspecified" and prevent XDG_SESSION_TYPE from being leveraged (and its "x11" fallback). --- src/platform/linux.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/linux.rs b/src/platform/linux.rs index 622685b..504dd73 100644 --- a/src/platform/linux.rs +++ b/src/platform/linux.rs @@ -104,7 +104,7 @@ pub fn get_display_server_of_session(session: &str) -> String { } else { "".to_owned() }; - if display_server.is_empty() || display_server == "tty" { + if display_server.is_empty() || display_server == "tty" || display_server == "unspecified" { if let Ok(sestype) = std::env::var("XDG_SESSION_TYPE") { if !sestype.is_empty() { return sestype.to_lowercase();