From 0a66eb9fb675df42d247b062e3f6435cd0474165 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 20 Jul 2023 21:06:42 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=E2=99=BB=20(flatpak-sync)=20Put=20code=20i?= =?UTF-8?q?n=20own=20method?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new method sync is at this point always called --- flatpak-sync/flatpak-sync.sh | 46 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/flatpak-sync/flatpak-sync.sh b/flatpak-sync/flatpak-sync.sh index 8e826a9..2870ed5 100755 --- a/flatpak-sync/flatpak-sync.sh +++ b/flatpak-sync/flatpak-sync.sh @@ -9,27 +9,31 @@ set -euo pipefail APPS_LIST_PATH="${APPS_LIST_PATH:=$HOME/.config/flatpak-sync/apps.list}" -readarray -t requested_apps < <(cat "$APPS_LIST_PATH") -readarray -t installed_apps < <(flatpak list --app --columns app | tail -n +1) +function sync() { + readarray -t requested_apps < <(cat "$APPS_LIST_PATH") + readarray -t installed_apps < <(flatpak list --app --columns app | tail -n +1) -declare -a requested_apps_cleaned=() + declare -a requested_apps_cleaned=() -echo "Checking for apps to install." -for app in "${requested_apps[@]}"; do - if [[ -z "$app" ]] || [[ "$app" =~ ^#.* ]]; then - continue - fi - requested_apps_cleaned+=("$app") - if [[ ! "${installed_apps[*]}" =~ "${app}" ]]; then - echo "$app not installed. Installing it." - flatpak install -y "$app" - fi -done + echo "Checking for apps to install." + for app in "${requested_apps[@]}"; do + if [[ -z "$app" ]] || [[ "$app" =~ ^#.* ]]; then + continue + fi + requested_apps_cleaned+=("$app") + if [[ ! "${installed_apps[*]}" =~ "${app}" ]]; then + echo "$app not installed. Installing it." + flatpak install -y "$app" + fi + done -echo "Checking for apps to remove." -for app in "${installed_apps[@]}"; do - if [[ ! "${requested_apps_cleaned[*]}" =~ "${app}" ]]; then - echo "$app no found in apps list. Removing it."; - flatpak uninstall -y "$app" - fi -done + echo "Checking for apps to remove." + for app in "${installed_apps[@]}"; do + if [[ ! "${requested_apps_cleaned[*]}" =~ "${app}" ]]; then + echo "$app no found in apps list. Removing it."; + flatpak uninstall -y "$app" + fi + done +} + +sync From 921aa2e03343335a01b31bba2adcbb5149f85f26 Mon Sep 17 00:00:00 2001 From: Marcel Kapfer Date: Thu, 20 Jul 2023 21:07:51 +0200 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=9A=A8=20(flatpak-sync)=20Ignore=20tw?= =?UTF-8?q?o=20irrelevant=20shellcheck=20warnings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flatpak-sync/flatpak-sync.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flatpak-sync/flatpak-sync.sh b/flatpak-sync/flatpak-sync.sh index 2870ed5..6150375 100755 --- a/flatpak-sync/flatpak-sync.sh +++ b/flatpak-sync/flatpak-sync.sh @@ -21,6 +21,7 @@ function sync() { continue fi requested_apps_cleaned+=("$app") + # shellcheck disable=SC2076 if [[ ! "${installed_apps[*]}" =~ "${app}" ]]; then echo "$app not installed. Installing it." flatpak install -y "$app" @@ -29,6 +30,7 @@ function sync() { echo "Checking for apps to remove." for app in "${installed_apps[@]}"; do + # shellcheck disable=SC2076 if [[ ! "${requested_apps_cleaned[*]}" =~ "${app}" ]]; then echo "$app no found in apps list. Removing it."; flatpak uninstall -y "$app"