DEV Community

Ivan Alejandro
Ivan Alejandro

Posted on • Originally published at ivanalejandro0.com

Use a custom data folder on Flatpak apps

The problem

You want to use different data/configuration folders for a Flatpak application, or maybe run multiple instances independent from each other.

I read through Flatpak's man pages, cli help and documentation but I didn't find a solution to my problem.

The solution

Run the flatpak app with a different HOME env variable.

env HOME=/path/to/your/custom/flatpak/home flatpak run your-app
Enter fullscreen mode Exit fullscreen mode

And that's pretty much it, everything related to running this specific app will be contained on that path you just used. And subsequent runs will work just as it would if you'd use the default home.

Example

For example, let's say we want a separate instance of Zoom (Zoom on Flathub) to run along the default one.

And also, let's use Flatseal to manage the flatpak app permissions.

I also created a couple of scripts to simplify the task of starting them up:

$ cat zoom.sh
#!/bin/sh
env HOME=$(pwd)/custom-flatpak-home flatpak run us.zoom.Zoom

$ cat flatseal.sh
#!/bin/sh
env HOME=$(pwd)/custom-flatpak-home flatpak run com.github.tchx84.Flatseal
Enter fullscreen mode Exit fullscreen mode

Here's how the data folder looks like:

~/apps/zoom.1$ tree -L 4 -a
.
├── custom-flatpak-home
│   ├── .cache
│   │   └── flatpak
│   │       └── system-cache
│   ├── Documents
│   │   └── Zoom
│   ├── .local
│   │   └── share
│   │       └── flatpak
│   ├── .var
│   │   └── app
│   │       ├── com.github.tchx84.Flatseal
│   │       └── us.zoom.Zoom
│   └── .zoom
│       ├── data
│       │   ├── com.zoom.ipc.assistantapp__req
│       │   ├── com.zoom.ipc.assistantapp__res
│       │   └── zoomus.enc.v2.db
│       ├── im
│       ├── logs
│       │   └── zoom_stdout_stderr.log
│       ├── reports
│       └── screenCapture
├── flatseal.sh
└── zoom.sh

19 directories, 6 files
Enter fullscreen mode Exit fullscreen mode

Use cases

How can you take advantage of this? or what could this be useful for?

  • logging in into multiple accounts on some app at the same time, maybe Teams or Zoom.
    • this can be useful to isolate them from each other, or
    • to use multiple accounts when it's not supported natively by the app
  • playing around with an app and its configurations without worrying about breaking your main working app
  • use this isolation to contain the data for a "disposable" instance you want to run, for tests/experiments/etc

Top comments (0)