This setup is a hands-free way to keep your Flatpak applications updated automatically. With the timer and service file, you don’t have to worry about manually checking for updates, as everything is done for you at regular intervals.
Timer Unit: tolga.timer
Create file: sudo nano ~/.config/systemd/user/tolga.timer
[Unit]
Description=Run Tolga's Service Every 5 Minutes VER:2.0A
[Timer]
OnBootSec=1min
OnUnitActiveSec=5min
Unit=tolga.service
[Install]
WantedBy=timers.target
This timer is responsible for triggering the service that handles Flatpak updates.
OnBootSec=1min: The timer will wait 1 minute after the system boots up before it starts the service.
OnUnitActiveSec=5min: After the service is activated, the timer will trigger it every 5 minutes. This ensures the service is checked and run repeatedly.
Unit=tolga.service: This tells the timer which service to start — the service named tolga.service.
Why is this useful?
My timer ensures that the Flatpak update process runs automatically in the background, without needing manual intervention. This is a hands-free way of making sure your Flatpak apps are always up to date.
Service Unit: tolga.service
Create file: sudo nano ~/.config/systemd/user/tolga.service
[Unit]
Description=Tolga's Flatpak Automatic Update and Notification VER:2.0A
Documentation=man:flatpak(1)
Wants=network-online.target
After=network-online.target
[Service]
Type=oneshot
ExecCondition=/bin/bash -c '[[ "$(busctl get-property org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.NetworkManager Metered | cut -c 3-)" == @(2[4] )]]'
ExecStart=/usr/bin/flatpak --system uninstall --unused -y --noninteractive ; /usr/bin/flatpak --system update -y --noninteractive ; /usr/bin/flatpak --system repair ; /usr/bin/notify-send "Flatpaks Updated" "Your computer is ready!" -app-name="Flatpak Update Service" -u NORMAL
TimeoutStopFailureMode=abort
Environment=SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=0
This service contains the commands to update and notify you about Flatpak updates.
Type=oneshot: The service runs once, completes its task, and then stops.
ExecCondition: This checks whether the network is metered (like on mobile networks) and prevents updates from running if the connection is metered.
ExecStart: This is where the updates actually happen:
- Uninstalls unused Flatpak apps
- Updates all Flatpak apps
- Repairs any issues with Flatpak installations
- Sends a notification when everything is done
TimeoutStopFailureMode=abort: If the service doesn’t stop correctly, it will abort and help you troubleshoot.
Environment=SYSTEMD_SLEEP_FREEZE_USER_SESSIONS=0: Ensures the service won’t be interrupted during sleep mode.