How to make flatpak applications use standard locations for user data files

flatpakxdg

Applications installed with Flatpak are keeping user data and configuration under ~/.var/app/ (see Wiki and documentation).

I would like the applications installed with Flatpak to reuse the configuration and data left from the system versions of the same applications. That is, I want them to keep user data in ~/.local/share, ~/.config, ~/.cache, instead of under ~/.var/app.

At first I was hoping that configuring environment variables XDG_CONFIG_HOME, XDG_DATA_HOME, XDG_CACHE_HOME could suffice, or that it could be enough to start the application with --filesystem options:

 $ flatpak run --filesystem=xdg-config --filesystem=xdg-cache \
  --filesystem=xdg-data <application-id>

However, this did not seem to work.

What is the correct way to make Flatpak applications reuse user data and configurations in standard locations?

Best Answer

I was able to get this to work by specifying the directory after --filesystem=xdg-config and including mount parameters after that. I'm not sure if the mount parameters are necessary, but try putting this in this finish-args section of your application's manifest .json.

"finish-args": [
    "--filesystem=xdg-config/<config-dir>:create",
    "--filesystem=xdg-cache/<cache-dir>:create",
    "--filesystem=xdg-data/<data-dir>:create"
],
Related Question