refact, option, allow linux headless

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2023-07-29 13:06:18 +08:00
parent 3c4852a254
commit c15e3c306e
5 changed files with 106 additions and 63 deletions

View File

@@ -9,6 +9,9 @@ use hbb_common::{
message_proto::Resolution,
regex::{Captures, Regex},
};
#[cfg(all(feature = "linux_headless"))]
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
use hbb_common::config::CONFIG_OPTION_ALLOW_LINUX_HEADLESS;
use std::{
cell::RefCell,
io::Write,
@@ -69,6 +72,13 @@ pub struct xcb_xfixes_get_cursor_image {
pub pixels: *const c_long,
}
#[inline]
#[cfg(feature = "linux_headless")]
#[cfg(not(any(feature = "flatpak", feature = "appimage")))]
pub fn is_headless_allowed() -> bool {
Config::get_option(CONFIG_OPTION_ALLOW_LINUX_HEADLESS) == "Y"
}
#[inline]
fn sleep_millis(millis: u64) {
std::thread::sleep(Duration::from_millis(millis));

View File

@@ -109,6 +109,10 @@ pub fn try_start_desktop(_username: &str, _passsword: &str) -> String {
// No need to verify password here.
return "".to_owned();
}
if username.is_empty() {
// Another user is logged in. No need to start a new xsession.
return "".to_owned();
}
if let Some(msg) = detect_headless() {
return msg.to_owned();