1
- use std:: path:: { PathBuf , MAIN_SEPARATOR } ;
1
+ use std:: {
2
+ env,
3
+ path:: { PathBuf , MAIN_SEPARATOR } ,
4
+ } ;
2
5
3
6
/// Try to determine the current target triple.
4
7
///
@@ -55,8 +58,12 @@ pub fn target_triple() -> crate::Result<String> {
55
58
///
56
59
/// On Windows, it's the path to the executable.
57
60
///
58
- /// On Linux, it's `/usr/lib/${exe_name}` when running the bundled app,
59
- /// and `${exe_dir}/../lib/${exe_name}` when running the app from `src-tauri/target/(debug|release)/`.
61
+ /// On Linux, when running in an AppImage the `APPDIR` variable will be set to
62
+ /// the mounted location of the app, and the resource dir will be
63
+ /// `${APPDIR}/usr/lib/${exe_name}`. If not running in an AppImage, the path is
64
+ /// `/usr/lib/${exe_name}`. When running the app from
65
+ /// `src-tauri/target/(debug|release)/`, the path is
66
+ /// `${exe_dir}/../lib/${exe_name}`.
60
67
///
61
68
/// On MacOS, it's `${exe_dir}../Resources` (inside .app).
62
69
pub fn resource_dir ( ) -> crate :: Result < PathBuf > {
@@ -80,6 +87,8 @@ pub fn resource_dir() -> crate::Result<PathBuf> {
80
87
if curr_dir. ends_with ( "/data/usr/bin" ) {
81
88
// running from the deb bundle dir
82
89
Ok ( exe_dir. join ( format ! ( "../lib/{}" , app_name) ) )
90
+ } else if let Ok ( appdir) = env:: var ( "APPDIR" ) {
91
+ Ok ( PathBuf :: from ( format ! ( "{}/usr/lib/{}" , appdir, app_name) ) )
83
92
} else {
84
93
// running bundle
85
94
Ok ( PathBuf :: from ( format ! ( "/usr/lib/{}" , app_name) ) )
0 commit comments