From 162f29c80d10e82ae4623cfe39ef625c078b5a20 Mon Sep 17 00:00:00 2001 From: Kingtous Date: Thu, 8 Dec 2022 17:08:31 +0800 Subject: [PATCH 1/3] fix: get display server in flatpak --- libs/hbb_common/src/platform/linux.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libs/hbb_common/src/platform/linux.rs b/libs/hbb_common/src/platform/linux.rs index 1a20ed0e1..8c3f2c85c 100644 --- a/libs/hbb_common/src/platform/linux.rs +++ b/libs/hbb_common/src/platform/linux.rs @@ -43,7 +43,8 @@ pub fn get_display_server() -> String { } fn get_display_server_of_session(session: &str) -> String { - if let Ok(output) = run_loginctl(Some(vec!["show-session", "-p", "Type", session])) + let mut display_server = if let Ok(output) = + run_loginctl(Some(vec!["show-session", "-p", "Type", session])) // Check session type of the session { let display_server = String::from_utf8_lossy(&output.stdout) @@ -76,16 +77,17 @@ 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 + "".to_owned() } } 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 the session is not a tty, then just return the type as usual + display_server } pub fn get_values_of_seat0(indices: Vec) -> Vec { @@ -126,8 +128,7 @@ pub fn get_values_of_seat0(indices: Vec) -> Vec { } fn is_active(sid: &str) -> bool { - if let Ok(output) = run_loginctl(Some(vec!["show-session", "-p", "State", sid])) - { + if let Ok(output) = run_loginctl(Some(vec!["show-session", "-p", "State", sid])) { String::from_utf8_lossy(&output.stdout).contains("active") } else { false From 7dadf3ba2f934435b7de4f4f08803bf542db0951 Mon Sep 17 00:00:00 2001 From: Kingtous Date: Thu, 8 Dec 2022 17:41:14 +0800 Subject: [PATCH 2/3] opt: remove redundant restore job --- flutter/lib/models/file_model.dart | 2 -- 1 file changed, 2 deletions(-) diff --git a/flutter/lib/models/file_model.dart b/flutter/lib/models/file_model.dart index 744a3a502..a7968f701 100644 --- a/flutter/lib/models/file_model.dart +++ b/flutter/lib/models/file_model.dart @@ -363,8 +363,6 @@ class FileModel extends ChangeNotifier { if (_currentRemoteDir.path.isEmpty) { openDirectory(_remoteOption.home, isLocal: false); } - // load last transfer jobs - await bind.sessionLoadLastTransferJobs(id: '${parent.target?.id}'); } Future onClose() async { From 3cfcaf65ad976d896698e7e1973e1f9e7c36016d Mon Sep 17 00:00:00 2001 From: Kingtous Date: Thu, 8 Dec 2022 17:43:46 +0800 Subject: [PATCH 3/3] 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