Building a flatpak - app configuration file

Mar 2, 2024
G

I’m building my first Flatpak.
My app uses a configuration file (lvnauth.conf) to store user settings, such as color preferences.

My question is: how can I make Flatpak not overwrite the configuration file each time my app has a new version? The problem I’m trying to avoid is replacing the user’s preferences on each new version of my Flatpak app.

I’m trying to get a clear picture as to what happens when a Flatpak app updates to a newer version of my app. Will it overwrite all the files to the newest version or just some files? What is the ideal way of dealing with configuration files?

C

Where is this configuration file? You can create a user config file at runtime in XDG_CONFIG_HOME (which will be inside ~/.var/app/) and flatpak will not touch it. It will work exactly the same as a native app. If, however, you create the file as e.g. ~/.lvnauth/lvnauth.conf, it will be lost on exit unless you make it --persist.

There’s nothing equivalent to /etc. You can install a file somewhere like /app/etc, but it would not be editable and would update with the app.

G
Replying to #2

The configuration file is currently in /app/bin/lvnauth.conf, but I’ll start using XDG_CONFIG_HOME
Thanks.