Skip to content

Commit

Permalink
fix some rare case
Browse files Browse the repository at this point in the history
  • Loading branch information
rustdesk committed Jun 10, 2021
1 parent c844d99 commit da46693
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/platform/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,23 +290,26 @@ fn get_display() -> String {
}
// above not work for gdm user
log::debug!("ls -l /tmp/.X11-unix/");
let mut last = "".to_owned();
if let Ok(output) = std::process::Command::new("ls")
.args(vec!["-l", "/tmp/.X11-unix/"])
.output()
{
for line in String::from_utf8_lossy(&output.stdout).lines() {
log::debug!(" {}", line);
let mut iter = line.split_whitespace();
if iter.nth(2) == Some(&user) {
if let Some(x) = iter.last() {
if x.starts_with("X") {
return x.replace("X", ":").to_owned();
let user_field = iter.nth(2);
if let Some(x) = iter.last() {
if x.starts_with("X") {
last = x.replace("X", ":").to_owned();
if user_field == Some(&user) {
return last;
}
}
}
}
}
"".to_owned()
last
}

fn get_value_of_seat0(i: usize) -> String {
Expand Down

0 comments on commit da46693

Please sign in to comment.