refact linux desktop env
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
e4c2e9af00
commit
6149c7f477
@ -769,6 +769,7 @@ mod desktop {
|
|||||||
pub protocal: String,
|
pub protocal: String,
|
||||||
pub display: String,
|
pub display: String,
|
||||||
pub xauth: String,
|
pub xauth: String,
|
||||||
|
pub is_rustdesk_subprocess: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Desktop {
|
impl Desktop {
|
||||||
@ -787,6 +788,11 @@ mod desktop {
|
|||||||
self.sid.is_empty()
|
self.sid.is_empty()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_headless(&self) -> bool {
|
||||||
|
self.sid.is_empty() || self.is_rustdesk_subprocess
|
||||||
|
}
|
||||||
|
|
||||||
fn get_display(&mut self) {
|
fn get_display(&mut self) {
|
||||||
self.display = get_env_tries("DISPLAY", &self.uid, GNOME_SESSION_BINARY, 10);
|
self.display = get_env_tries("DISPLAY", &self.uid, GNOME_SESSION_BINARY, 10);
|
||||||
if self.display.is_empty() {
|
if self.display.is_empty() {
|
||||||
@ -901,6 +907,16 @@ mod desktop {
|
|||||||
last
|
last
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_is_subprocess(&mut self) {
|
||||||
|
self.is_rustdesk_subprocess = false;
|
||||||
|
let cmd = "ps -ef | grep 'rustdesk/xorg.conf' | grep -v grep | wc -l";
|
||||||
|
if let Ok(res) = run_cmds(cmd) {
|
||||||
|
if res.trim() != "0" {
|
||||||
|
self.is_rustdesk_subprocess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn refresh(&mut self) {
|
pub fn refresh(&mut self) {
|
||||||
if !self.sid.is_empty() && is_active(&self.sid) {
|
if !self.sid.is_empty() && is_active(&self.sid) {
|
||||||
return;
|
return;
|
||||||
@ -909,6 +925,7 @@ mod desktop {
|
|||||||
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
let seat0_values = get_values_of_seat0(&[0, 1, 2]);
|
||||||
if seat0_values[0].is_empty() {
|
if seat0_values[0].is_empty() {
|
||||||
*self = Self::default();
|
*self = Self::default();
|
||||||
|
self.is_rustdesk_subprocess = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -924,6 +941,9 @@ mod desktop {
|
|||||||
|
|
||||||
self.get_display();
|
self.get_display();
|
||||||
self.get_xauth();
|
self.get_xauth();
|
||||||
|
self.set_is_subprocess();
|
||||||
|
|
||||||
|
println!("REMOVE ME ======================================= desktop: {:?}", self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user