From 692f8c845425f9a9d604ff8f15ba3a7e2fc3d0c9 Mon Sep 17 00:00:00 2001
From: GyDi <zzzgydi@gmail.com>
Date: Sat, 11 Feb 2023 23:19:08 +0800
Subject: [PATCH] fix: appimage auto launch, close #403

---
 src-tauri/src/core/sysopt.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src-tauri/src/core/sysopt.rs b/src-tauri/src/core/sysopt.rs
index ea7f401..5acd53e 100644
--- a/src-tauri/src/core/sysopt.rs
+++ b/src-tauri/src/core/sysopt.rs
@@ -171,6 +171,26 @@ impl Sysopt {
         })()
         .unwrap_or(app_path);
 
+        // fix #403
+        #[cfg(target_os = "linux")]
+        let app_path = {
+            use core::handle::Handle;
+            use tauri::Manager;
+
+            let handle = Handle::global();
+            handle
+                .app_handle
+                .lock()
+                .map(|app_handle| {
+                    app_handle
+                        .env()
+                        .appimage
+                        .and_then(|p| p.to_str().map(|s| s.to_string()))
+                })
+                .unwrap_or(Some(app_path))
+                .unwrap()
+        };
+
         let auto = AutoLaunchBuilder::new()
             .set_app_name(app_name)
             .set_app_path(&app_path)
-- 
GitLab