From a37c51041815deafa02fc0bfa54b80b1b7350728 Mon Sep 17 00:00:00 2001 From: Robin Candau <53110319+Antiz96@users.noreply.github.com> Date: Fri, 10 Nov 2023 20:00:00 +0100 Subject: [PATCH] Only search for unused Flatpak packages if flatpak is installed (#57) --- src/script/arch-update.sh | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/src/script/arch-update.sh b/src/script/arch-update.sh index 3b3d2c3..e4189b7 100755 --- a/src/script/arch-update.sh +++ b/src/script/arch-update.sh @@ -238,26 +238,28 @@ orphan_packages() { echo -e "No orphan package found\n" fi - if [ -n "${flatpak_unused}" ]; then - echo -e "--Flatpak Unused Packages--\n${flatpak_unused}\n" + if [ -n "${flatpak}" ]; then + if [ -n "${flatpak_unused}" ]; then + echo -e "--Flatpak Unused Packages--\n${flatpak_unused}\n" + + if [ "$(echo "${flatpak_unused}" | wc -l)" -eq 1 ]; then + read -rp $'Would you like to remove this Flatpak unused package now? [y/N] ' answer + else + read -rp $'Would you like to remove these Flatpak unused packages now? [y/N] ' answer + fi - if [ "$(echo "${flatpak_unused}" | wc -l)" -eq 1 ]; then - read -rp $'Would you like to remove this Flatpak unused package now? [y/N] ' answer + case "${answer}" in + [Yy]) + echo -e "\n--Removing Flatpak Unused Packages--" + flatpak remove --unused && echo -e "\nThe removal has been applied\n" || echo -e >&2 "\nAn error has occurred\nThe removal has been aborted\n" + ;; + *) + echo -e "The removal hasn't been applied\n" + ;; + esac else - read -rp $'Would you like to remove these Flatpak unused packages now? [y/N] ' answer + echo -e "No Flatpak unused package found\n" fi - - case "${answer}" in - [Yy]) - echo -e "\n--Removing Flatpak Unused Packages--" - flatpak remove --unused && echo -e "\nThe removal has been applied\n" || echo -e >&2 "\nAn error has occurred\nThe removal has been aborted\n" - ;; - *) - echo -e "The removal hasn't been applied\n" - ;; - esac - else - echo -e "No Flatpak unused package found\n" fi }