diff --git a/src/platform/linux.rs b/src/platform/linux.rs
index 5099c9717..838d2eae4 100644
--- a/src/platform/linux.rs
+++ b/src/platform/linux.rs
@@ -164,7 +164,7 @@ pub fn start_os_service() {
             uid = tmp;
             log::info!("uid of seat0: {}", uid);
             let gdm = format!("/run/user/{}/gdm/Xauthority", uid);
-            let mut auth = get_env("XAUTHORITY", &uid);
+            let mut auth = get_env_tries("XAUTHORITY", &uid, 10);
             if auth.is_empty() {
                 auth = if std::path::Path::new(&gdm).exists() {
                     gdm
@@ -502,6 +502,17 @@ fn run_cmds(cmds: String) -> ResultType<Option<String>> {
     }
 }
 
+fn get_env_tries(name: &str, uid: &str, n: usize) -> String {
+    for _ in 0..n {
+        let x = get_env(name, uid);
+        if !x.is_empty() {
+            return x;
+        }
+        std::thread::sleep(std::time::Duration::from_millis(300));
+    }
+    "".to_owned()
+}
+
 fn get_env(name: &str, uid: &str) -> String {
     let cmd = format!("ps -u {} -o pid= | xargs -I__ cat /proc/__/environ 2>/dev/null | tr '\\0' '\\n' | grep -m1 '^{}=' | sed 's/{}=//g'", uid, name, name);
     log::debug!("Run: {}", &cmd);