[Unit]
Description=Update user Flatpaks
[Service]
Type=oneshot
ExecStart=/usr/bin/flatpak update --assumeyes --noninteractive
[Install]
WantedBy=default.target
elementary OS 5.1 doesn’t automatically update Flatpak applications. Given the arbitrary appearance of updates, it’s a bit bothersome to be nagged about updates all day. Flatpak doesn’t provide an auto-update mechanism but instead leaves this up to software apps. GNOME Software has had this functionality baked-in since GNOME 3.30, for instance, according to the Phoronix article GNOME Software 3.30 Will Automatically Update Flatpaks By Default. Since I don’t want to have multiple app stores on my machine, I opted for using systemd to update Flatpaks.
The instructions here describe how to create systemd service and timers to automate updating both user and system Flatpak installations. The system systemd units will only update the system Flatpaks, whereas the user systemd units will update both the user’s Flatpaks and the system’s. In most cases, having both user and system services to update Flatpaks is unnecessary. The system systemd units are handy for the default Flatpak behavior, which installs Flatpaks system-wide. The user systemd units are great for users who opt to install Flatpaks in their user-specific installation, such as Flatpak developers.
The tutorial uses elementary OS 5.1 as a reference operating system but are more generally applicable to any Linux system with systemd and Flatpak. I assume you are familiar with these concepts and will keep things brief. Separate instructions are provided for the user and system Flatpak installations. The systemd units here were derived from those provided by marcelpaulo's GitHub comment.
The systemd user unit files are placed in the directory |
Create the systemd service unit to update Flatpaks.
[Unit]
Description=Update user Flatpaks
[Service]
Type=oneshot
ExecStart=/usr/bin/flatpak update --assumeyes --noninteractive
[Install]
WantedBy=default.target
[Unit]
Description=Update system Flatpaks
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
ExecStart=/usr/bin/flatpak update --assumeyes --noninteractive --system
[Install]
WantedBy=multi-user.target
Create the systemd timer unit to automate the updates.
[Unit]
Description=Update user Flatpaks daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
[Unit]
Description=Update system Flatpaks daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Start the systemd timer.
systemctl --user enable --now update-user-flatpaks.timer
Created symlink /home/jordan/.config/systemd/user/timers.target.wants/update-user-flatpaks.timer → /etc/systemd/user/update-user-flatpaks.timer.
sudo systemctl --system enable --now update-system-flatpaks.timer
Created symlink /etc/systemd/system/timers.target.wants/update-system-flatpaks.timer → /etc/systemd/system/update-system-flatpaks.timer.
You have removed a bit of distraction from your day. With any luck, it wasn’t even too difficult.