-
Notifications
You must be signed in to change notification settings - Fork 9
Apps that require writing inside the AppImage
Most Linux games and applications will use the application directory inside the AppImage as a read-only directory, and direct all the writes to a directory somewhere under your $HOME.
However, other applications will insist on writing inside the application directory, which is impossible inside an AppImage, because they're just a read-only ISO image.
If it's not possible to make the application write somewhere else, we have two workarounds:
We can use a unionfs to let the application write as much as it likes inside the data directory, and redirect all the writes to another directory using a COW (Copy-on-Write) strategy.
This method is elegant, but it may be tricky to make work on some systems, because it requires you to embed a unionfs-fuse
binary inside the AppImage (usually under $APPDIR/usr/bin/
, because the default AppRun script pushes that directory into the $PATH
), which needs to talk to the kernel, and it may fail if the binary and kernel versions are too far apart. However this requires extensive testing.
This is the snipplet we have to use in the AppRun script, in order to setup the mountpoints.
RO_DATADIR="$APPDIR/_MY_APPLICATION_"
RW_DATADIR="$HOME/.local/share/AppImage/_MY_APPLICATION_unionfs"
unionfs_overlay_setup "$RO_DATADIR" "$RW_DATADIR" || exit 1
cd "$RW_DATADIR"
We can just symlink all the data files to a writable directory before running our program, and copy the configuration files so they can be modified.
This method is pretty dirty, but it's pretty much granted to work on all systems, because it only depends on standard tools like ln
, cp
and mkdir
.
This is the snipplet we have to use in the AppRun script, in order to setup the symlinks.
RO_DATADIR="$APPDIR/_MY_APPLICATION_"
RW_DATADIR="$HOME/.local/share/AppImage/_MY_APPLICATION_link"
link_overlay_setup "$RO_DATADIR" "$RW_DATADIR" || exit 1
cd "$RW_DATADIR"
By default, the link_overlay_setup
function, defined un util.sh
, will replicate the directory structure of your $RO_DATADIR
, symlinking all the files except those with *.ini, *.cfg and *.dat extension, which usually is a sane default. If you application uses different extensions in its configuration files, you can adapt util.sh
to your specific needs.