[HowTo] Check if your Flatpaks have been updated

Recently i had to start using 1-2 Flatpaks. Although the Pamac integration works well, i decided i want to keep Pamac only doing system updates and not update Repo and Flatpak in one transaction, because under some circumstances it can lead to problems. Unfortunately pamac has no option to only notify for flatpak updates, if you enable updates it will also want to install them (not allowing you to update the repos otherwise).

So i decided to disable the flatpak update function in pamac follow the excellent tutorial from @linux-aarhus for AUR scripts

and do something very similar. Here is the resulting check-flatpak.sh script that you can add to startup (do not forget to make executable). It waits a bit after boot and checks for flatpak updates and in case any are found shows a popup, after that it is up to you to update with flatpak update

#!/usr/bin/env bash
#
# Flatpak update checker - notify without updating
#
# License: GNU GPL
# ver. 2024-03-06 by Teo

sleep 75

#check if libnotify is available
if ! [[ "$(which notify-send)" =~ (notify-send) ]]; then
	echo ":: libnotify not found... sudo pacman -S libnotify"
	exit 1
fi

flatpaks_updated=$(flatpak remote-ls --updates)

if ! [[ -z ${flatpaks_updated} ]]; then
        notify-send -u normal "Flatpak updates available, use flatpak update"  "$flatpaks_updated"
fi

1 Like

Why is this nessacary as Pamac can also notify you if flatpak updates are available?

Because if there are also system updates you cannot choose what to install. If something in the flatpak fails it will also stop the system updates.
Of course, in such case one can update with pacman -Syu first, which does not support flatpaks. But i just wanted to avoid such possibility altogether.

1 Like

Ideally pamac had the ability to do a staged update, first repos, second aur, third flatpak.

Pamac does know how to handle flatpaks out-of-box and somewhere in pamac there is a flatpak repo defined.
I believe above script still assumes the installation of flatpaks through pamac. On my system flatpak installation via cli required to set the flatpak repo before I could actually use flatpak update:

Example:

flatpak remote-add --if-not-exists --subset=verified flathub-verified https://flathub.org/repo/flathub.flatpakrepo

Use flatpak remotes to verify if that has been done

flatpak remotes
Name             Optionen
flathub          system
flathub-verified system

It assumes a working flatpak installation (flatpak installed, remote defined). I have installed flatpaks through pamac and through terminal. Pamac by default sets up the remote flathub as the only one.
If you have other remotes, the script has to be modified to specify remote

flatpak remote-ls --updates some_other_remote