@@ -524,6 +524,27 @@ bool build_mount_point(char* mount_dir, const char* const argv0, char const* con
524
524
mount_dir [templen + 8 + namelen + 6 ] = 0 ; // null terminate destination
525
525
}
526
526
527
+ void set_portable_home_and_config (char * basepath ) {
528
+ char portable_home_dir [PATH_MAX ];
529
+ char portable_config_dir [PATH_MAX ];
530
+
531
+ /* If there is a directory with the same name as the AppImage plus ".home", then export $HOME */
532
+ strcpy (portable_home_dir , basepath );
533
+ strcat (portable_home_dir , ".home" );
534
+ if (is_writable_directory (portable_home_dir )){
535
+ fprintf (stderr , "Setting $HOME to %s\n" , portable_home_dir );
536
+ setenv ("HOME" ,portable_home_dir ,1 );
537
+ }
538
+
539
+ /* If there is a directory with the same name as the AppImage plus ".config", then export $XDG_CONFIG_HOME */
540
+ strcpy (portable_config_dir , basepath );
541
+ strcat (portable_config_dir , ".config" );
542
+ if (is_writable_directory (portable_config_dir )){
543
+ fprintf (stderr , "Setting $XDG_CONFIG_HOME to %s\n" , portable_config_dir );
544
+ setenv ("XDG_CONFIG_HOME" ,portable_config_dir ,1 );
545
+ }
546
+ }
547
+
527
548
int main (int argc , char * argv []) {
528
549
char appimage_path [PATH_MAX ];
529
550
char argv0_path [PATH_MAX ];
@@ -731,6 +752,8 @@ int main(int argc, char *argv[]) {
731
752
setenv ("ARGV0" , argv0_path , 1 );
732
753
setenv ("APPDIR" , prefix , 1 );
733
754
755
+ set_portable_home_and_config (fullpath );
756
+
734
757
execv (apprun_path , new_argv );
735
758
736
759
int error = errno ;
@@ -912,24 +935,7 @@ int main(int argc, char *argv[]) {
912
935
setenv ( "ARGV0" , argv0_path , 1 );
913
936
setenv ( "APPDIR" , mount_dir , 1 );
914
937
915
- char portable_home_dir [PATH_MAX ];
916
- char portable_config_dir [PATH_MAX ];
917
-
918
- /* If there is a directory with the same name as the AppImage plus ".home", then export $HOME */
919
- strcpy (portable_home_dir , fullpath );
920
- strcat (portable_home_dir , ".home" );
921
- if (is_writable_directory (portable_home_dir )){
922
- fprintf (stderr , "Setting $HOME to %s\n" , portable_home_dir );
923
- setenv ("HOME" ,portable_home_dir ,1 );
924
- }
925
-
926
- /* If there is a directory with the same name as the AppImage plus ".config", then export $XDG_CONFIG_HOME */
927
- strcpy (portable_config_dir , fullpath );
928
- strcat (portable_config_dir , ".config" );
929
- if (is_writable_directory (portable_config_dir )){
930
- fprintf (stderr , "Setting $XDG_CONFIG_HOME to %s\n" , portable_config_dir );
931
- setenv ("XDG_CONFIG_HOME" ,portable_config_dir ,1 );
932
- }
938
+ set_portable_home_and_config (fullpath );
933
939
934
940
/* Original working directory */
935
941
char cwd [1024 ];
0 commit comments