How does an appimage persist settings between launches?
By popular request, I'm asking how do AppImages, which are read-only and stay compressed, store their settings.
From the AppImageKit README:
Special directories
Normally the application contained inside an AppImage will store its configuration files wherever it normally stores them (most frequently somewhere inside
$HOME
). If you invoke an AppImage built with a recent version of AppImageKit and have one of these special directories in place, then the configuration files will be stored alongside the AppImage. This can be useful for portable use cases, e.g., carrying an AppImage on a USB stick, along with its data.
- If there is a directory with the same name as the AppImage plus
.home
, then$HOME
will automatically be set to it before executing the payload application- If there is a directory with the same name as the AppImage plus
.config
, then$XDG_CONFIG_HOME
will automatically be set to it before executing the payload application
@muru's answer of course is correct and should be upvoted and accepted.
Let me add a few points for clarity:
-
You can make the AppImage create the two directories all by itself by invoking it with the
--appimage-portable-home
and--appimage-portable-config
parameters. This has to be done only once:../some/path/to/my.AppImage --appimage-portable-home ../some/path/to/my.AppImage --appimage-portable-config
This will create the respective (initially empty) directories:
- The AppImage will then think that
../some/path/to/my.AppImage.home/
is$HOME
. -
The AppImage will also think that
../some/path/to/my.AppImage.config/
is$XDG_CONFIG_HOME
.(BTW,
$XDG_CONFIG_HOME
very frequently defaults to$HOME/.config
.)
- The AppImage will then think that
If you find above two parameters too difficult to remember, then memorize another one:
--appimage-help
. Using that will list and explain all the others which are available.Not every application makes use of
$HOME
or$XDG_CONFIG_HOME
. In this case your newly created directories will remain empty. Otherwise they'll be populated by the AppImage's payload at runtime and when exiting to all settings it wants to remember.Many applications make use of only one of the two environment variables,
$HOME
or$XDG_CONFIG_HOME
(and therefore ofmy.AppImage.home/
resp.my.AppImage.config/
), not both.Some applications may even get confused if both of the portable settings directories exist...
If you re-name the
old.AppImage
tonew.AppImage
, theold.AppImage.home/
andold.AppImage.config/
directories immediately cease to work. You need to rename the two directories accordingly:new.AppImage.home/
andnew.AppImage.config/
.If you rename awesome.AppImage to simply awesome, you have to rename the
awesome.AppImage.home/
directory too: namely, toawesome.home/
.If you move the AppImage to a new location and want to keep the previously used config and home directories, you have to move these too.
If you want to get rid of the old configuration and want to make the AppImage again use "standard" paths for
$HOME
for$XDG_CONFIG_HOME
then simply delete these directories again.-
If you want a new AppImage's payload to use the same settings as your system-installed version of the payload app, then you should:
- Create the relevant empty directory first;
- Locate the respective config directory of the system-installed app;
- Copy all content of that directory to the new empty one.
in Ubuntu, the AppImage will store the settings by default in:
/home/user_name/.config/my_App_name
-
/home/lwbaqueros/.my_App_name
If you delete those folders, you will have a fresh version of your AppImage app