1- use std:: path:: { PathBuf , MAIN_SEPARATOR } ;
1+ use std:: {
2+ env,
3+ path:: { PathBuf , MAIN_SEPARATOR } ,
4+ } ;
25
36/// Try to determine the current target triple.
47///
@@ -55,8 +58,12 @@ pub fn target_triple() -> crate::Result<String> {
5558///
5659/// On Windows, it's the path to the executable.
5760///
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}`.
6067///
6168/// On MacOS, it's `${exe_dir}../Resources` (inside .app).
6269pub fn resource_dir ( ) -> crate :: Result < PathBuf > {
@@ -80,6 +87,8 @@ pub fn resource_dir() -> crate::Result<PathBuf> {
8087 if curr_dir. ends_with ( "/data/usr/bin" ) {
8188 // running from the deb bundle dir
8289 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) ) )
8392 } else {
8493 // running bundle
8594 Ok ( PathBuf :: from ( format ! ( "/usr/lib/{}" , app_name) ) )
0 commit comments