diff --git a/config/files/usr/bin/user-flatpak-setup b/config/files/usr/bin/user-flatpak-setup index 9e2d2ab0..affb5bd9 100755 --- a/config/files/usr/bin/user-flatpak-setup +++ b/config/files/usr/bin/user-flatpak-setup @@ -17,6 +17,29 @@ if grep -qz 'fedora' <<< $(flatpak remotes); then fi flatpak remote-add --if-not-exists --user flathub-user https://flathub.org/repo/flathub.flatpakrepo +# Lists of flatpaks +FLATPAK_LIST=$(flatpak list --columns=application) +INSTALL_LIST=$(cat /etc/flatpak/user-install) +REMOVE_LIST=$(cat /etc/flatpak/user-remove) + +# Install flatpaks in list +if [[ -n $INSTALL_LIST ]]; then + for flatpak in $INSTALL_LIST; do + if grep -qvz $flatpak <<< $FLATPAK_LIST; then + flatpak install --user --noninteractive flathub-user $flatpak + fi + done +fi + +# Remove flatpaks in list +if [[ -n $REMOVE_LIST ]]; then + for flatpak in $REMOVE_LIST; do + if grep -qz $flatpak <<< $FLATPAK_LIST; then + flatpak remove --user --noninteractive $flatpak + fi + done +fi + # Prevent future executions echo "Writing state file" mkdir -p $HOME/.config/ublue-os/