How can I set a flatpak application to run on startup?

6.3k views Asked by At

I wanted to post this because I didn't find the answer elsewhere and this might just help someone else.

I have Slack installed on my Ubuntu 18.04 Bionic Beaver via FlatPak and would like to have it launch as soon as I login. Because it is installed via FlatPak, I cannot find it in /usr/share/applications in order to add it to startup applications

3

There are 3 answers

0
dorothy Dorothy On

You need to install FlatPak applications via Gnome Tweaks. If you haven't already installed Gnome tweaks then run

sudo apt install gnome-tweaks

Launch Gnome Tweaks and navigate to "Startup Applications".

enter image description here

The flatPak applications are easily found from here.

1
nectarine On

You could add an entry to your .gnomerc, .Xinitrc etc such as

snap run (program)

0
manero On

While it is technically correct to say "run on startup", it is better to say "run on login" in this case.

An flatpak application like Slack should be launched after the user logged in, and not before that.
But a flatpak application like Jellyfin Server could also start regardless if the user logged in, so this is more akin to "run on startup".

I point this out because there are many scenarios and different ways to achieve them.
The Arch-Linux wiki covers many of them, based on Desktop-Environment, Window-Manager, etc.:

Now to return to Ubuntu and Gnome:

When adding a startup application via Gnome Tweaks, a .desktop file is created under ~/.config/autostart.

With that in mind one can create custom .desktop files in that directory.
For example here is a custom file to launch flatpak's PCSX2 after the user logged in:

cat ~/.config/autostart/test-PCSX2.desktop

[Desktop Entry]
Type=Application
Name=test-PCSX2
Exec=flatpak run net.pcsx2.PCSX2

These files can be tested by logging-out and logging-in again, no full restart needed :)