2024-05-05 10:27:56 +00:00
#!/usr/bin/env bash
2024-05-05 15:09:31 +00:00
# TODO: handle multiple remotes, maybe with yaml config?
2024-05-05 11:19:06 +00:00
REPO_NAME=flathub
2024-05-05 10:27:56 +00:00
# Installed flatpaks
2024-05-05 15:09:31 +00:00
FLATPAK_LIST=$(flatpak list --app --columns=application)
2024-05-05 10:27:56 +00:00
# Flatpak list files
INSTALL_LIST_FILE="/usr/share/azure/flatpaks/install"
USER_INSTALL_LIST_FILE="/etc/azure/flatpaks/install"
# Prefer user's install + remove list over maintainer's, in case when same flatpak ID is present in maintainer's install list + user's remove list & vice-versa
# Also ignores words starting with # symbol, whitelines & duplicate entries
MAINTAINER_INSTALL_LIST=$(sort "$INSTALL_LIST_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++')
# Combine maintainer & user list. Ignore words starting with # symbol, whitelines & duplicate entries
COMBINED_INSTALL_LIST=$(cat <(echo "$MAINTAINER_INSTALL_LIST") "$USER_INSTALL_LIST_FILE" | grep -v -E '^#|^$' | awk '!seen[$0]++')
# Install flatpaks in list
if [[ -f $INSTALL_LIST_FILE ]] || [[ -f $USER_INSTALL_LIST_FILE ]]; then
if [[ -n $FLATPAK_LIST ]]; then
INSTALL_LIST=$(comm -23 <(echo "$COMBINED_INSTALL_LIST" | sort) <(echo "$FLATPAK_LIST" | sort))
else
INSTALL_LIST="$COMBINED_INSTALL_LIST"
fi
notify-send "Flatpak Installer" "Started install of user flatpaks" --app-name="Flatpak Installer" -u NORMAL
2024-05-05 15:09:31 +00:00
flatpak install --noninteractive "$REPO_NAME" ${INSTALL_LIST[@]}
2024-05-05 10:27:56 +00:00
notify-send "Flatpak Installer" "Finished install of user flatpaks:\n$INSTALL_LIST" --app-name="Flatpak Installer" -u NORMAL
fi