fix: add support for headless in docker (#7811)

This commit is contained in:
Cong Zhang 2024-04-24 01:47:45 +00:00 committed by GitHub
parent 67ee3a5a67
commit bc68f400f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,6 +49,16 @@ pub fn is_x11_or_headless() -> bool {
const INVALID_SESSION: &str = "4294967295"; const INVALID_SESSION: &str = "4294967295";
pub fn get_display_server() -> String { pub fn get_display_server() -> String {
// Check for forced display server environment variable first
if let Ok(forced_display) = std::env::var("RUSTDESK_FORCED_DISPLAY_SERVER") {
return forced_display;
}
// Check if `loginctl` can be called successfully
if run_loginctl(None).is_err() {
return DISPLAY_SERVER_X11.to_owned();
}
let mut session = get_values_of_seat0(&[0])[0].clone(); let mut session = get_values_of_seat0(&[0])[0].clone();
if session.is_empty() { if session.is_empty() {
// loginctl has not given the expected output. try something else. // loginctl has not given the expected output. try something else.