From 74c6dd679233a66c17462a40d8fb2bc4608267bc Mon Sep 17 00:00:00 2001 From: fnrir Date: Wed, 5 Jul 2023 10:17:56 +0200 Subject: [PATCH] Use different resource path in certain cases This is janky, but does not require AppHandle. --- src-tauri/src/system_helpers.rs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/system_helpers.rs b/src-tauri/src/system_helpers.rs index 71dd9c1..a7f8338 100644 --- a/src-tauri/src/system_helpers.rs +++ b/src-tauri/src/system_helpers.rs @@ -119,10 +119,28 @@ pub fn open_in_browser(url: String) { pub fn install_location() -> String { let mut exe_path = std::env::current_exe().unwrap(); - // Get the path to the executable. - exe_path.pop(); + #[cfg(windows)] + { + // Get the path to the executable. + exe_path.pop(); - return exe_path.to_str().unwrap().to_string(); + return exe_path.to_str().unwrap().to_string(); + } + #[cfg(target_os = "linux")] + { + let bin_name = exe_path.file_name().unwrap().to_str().unwrap().to_string(); + exe_path.pop(); + if exe_path.starts_with("/usr/bin") { + let mut path = PathBuf::from("/usr/lib"); + path.push(bin_name); + path + } else { + exe_path + } + .to_str() + .unwrap() + .to_string() + } } #[tauri::command]