get values of seat0, do not filter gdm
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
9ef4f4c1de
commit
34c3615320
@ -135,7 +135,7 @@ pub fn get_values_of_seat0_with_gdm_wayland(indices: &[usize]) -> Vec<String> {
|
||||
fn _get_values_of_seat0(indices: &[usize], ignore_gdm_wayland: bool) -> Vec<String> {
|
||||
if let Ok(output) = run_loginctl(None) {
|
||||
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
||||
if !line.contains("gdm") && line.contains("seat0") {
|
||||
if line.contains("seat0") {
|
||||
if let Some(sid) = line.split_whitespace().next() {
|
||||
if is_active(sid) {
|
||||
if ignore_gdm_wayland {
|
||||
|
@ -56,7 +56,7 @@ pub static ref T: std::collections::HashMap<&'static str, &'static str> =
|
||||
("show_monitors_tip", "Show monitors in toolbar."),
|
||||
("enter_rustdesk_passwd_tip", "Enter RustDesk password"),
|
||||
("remember_rustdesk_passwd_tip", "Remember RustDesk password"),
|
||||
("login_linux_tip", "Remote desktop is unready. Please \n 1. Login on remote side and then try again\n 2. Or input remote account to login and start a X desktop session"),
|
||||
("login_linux_tip", "You need to login to remote Linux account to enable a X desktop session"),
|
||||
("verify_rustdesk_password_tip", "Veryfy RustDesk password"),
|
||||
("remember_account_tip", "Remember this account"),
|
||||
("remember_password_tip", "Remember password"),
|
||||
|
@ -357,6 +357,7 @@ pub fn start_os_service() {
|
||||
&mut last_restart,
|
||||
&mut user_server,
|
||||
) {
|
||||
stop_xorg_subprocess();
|
||||
force_stop_server();
|
||||
start_server(
|
||||
Some((desktop.uid.clone(), desktop.username.clone())),
|
||||
@ -402,6 +403,12 @@ pub fn get_active_userid() -> String {
|
||||
get_values_of_seat0(&[1])[0].clone()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_gdm_user(username: &str) -> bool {
|
||||
username == "gdm"
|
||||
// || username == "lightgdm"
|
||||
}
|
||||
|
||||
fn get_cm() -> bool {
|
||||
if let Ok(output) = Command::new("ps").args(vec!["aux"]).output() {
|
||||
for line in String::from_utf8_lossy(&output.stdout).lines() {
|
||||
@ -800,6 +807,11 @@ mod desktop {
|
||||
self.sid.is_empty()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_login_wayland(&self) -> bool {
|
||||
super::is_gdm_user(&self.username) && self.protocal == ENV_DESKTOP_PROTOCAL_WAYLAND
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_headless(&self) -> bool {
|
||||
self.sid.is_empty() || self.is_rustdesk_subprocess
|
||||
|
@ -23,6 +23,7 @@ lazy_static::lazy_static! {
|
||||
#[derive(Debug)]
|
||||
struct DesktopManager {
|
||||
seat0_username: String,
|
||||
seat0_display_server: String,
|
||||
child_username: String,
|
||||
child_exit: Arc<AtomicBool>,
|
||||
is_child_running: Arc<AtomicBool>,
|
||||
@ -61,8 +62,8 @@ pub fn stop_xdesktop() {
|
||||
pub fn try_start_x_session(username: &str, password: &str) -> ResultType<(String, bool)> {
|
||||
let mut desktop_manager = DESKTOP_MANAGER.lock().unwrap();
|
||||
if let Some(desktop_manager) = &mut (*desktop_manager) {
|
||||
if !desktop_manager.seat0_username.is_empty() {
|
||||
return Ok((desktop_manager.seat0_username.clone(), true));
|
||||
if let Some(seat0_username) = desktop_manager.get_supported_display_seat0_username() {
|
||||
return Ok((seat0_username, true));
|
||||
}
|
||||
|
||||
let _ = desktop_manager.try_start_x_session(username, password)?;
|
||||
@ -86,14 +87,16 @@ pub fn is_headless() -> bool {
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_ref()
|
||||
.map_or(false, |manager| manager.seat0_username.is_empty())
|
||||
.map_or(false, |manager| {
|
||||
manager.get_supported_display_seat0_username().is_none()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn get_username() -> String {
|
||||
match &*DESKTOP_MANAGER.lock().unwrap() {
|
||||
Some(manager) => {
|
||||
if !manager.seat0_username.is_empty() {
|
||||
manager.seat0_username.clone()
|
||||
if let Some(seat0_username) = manager.get_supported_display_seat0_username() {
|
||||
seat0_username
|
||||
} else {
|
||||
if manager.is_running() && !manager.child_username.is_empty() {
|
||||
manager.child_username.clone()
|
||||
@ -119,28 +122,40 @@ impl DesktopManager {
|
||||
|
||||
pub fn new() -> Self {
|
||||
let mut seat0_username = "".to_owned();
|
||||
let mut seat0_display_server = "".to_owned();
|
||||
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
||||
println!(
|
||||
"REMOVE ME ================================== DesktopManager: {:?}",
|
||||
&seat0_values
|
||||
);
|
||||
if !seat0_values[0].is_empty() {
|
||||
let display_server = get_display_server_of_session(&seat0_values[1]);
|
||||
if display_server == ENV_DESKTOP_PROTOCAL_X11
|
||||
|| display_server == ENV_DESKTOP_PROTOCAL_WAYLAND
|
||||
{
|
||||
seat0_username = seat0_values[2].clone();
|
||||
}
|
||||
seat0_display_server = get_display_server_of_session(&seat0_values[1]);
|
||||
}
|
||||
|
||||
Self {
|
||||
seat0_username,
|
||||
seat0_display_server,
|
||||
child_username: "".to_owned(),
|
||||
child_exit: Arc::new(AtomicBool::new(true)),
|
||||
is_child_running: Arc::new(AtomicBool::new(false)),
|
||||
}
|
||||
}
|
||||
|
||||
fn get_supported_display_seat0_username(&self) -> Option<String> {
|
||||
if is_gdm_user(&self.seat0_username)
|
||||
&& self.seat0_display_server == ENV_DESKTOP_PROTOCAL_WAYLAND
|
||||
{
|
||||
None
|
||||
} else {
|
||||
if self.seat0_username.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(self.seat0_username.clone())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn get_xauth() -> String {
|
||||
let xauth = get_env_var("XAUTHORITY");
|
||||
|
Loading…
Reference in New Issue
Block a user