Skip to content

Commit

Permalink
Only search for unused Flatpak packages if flatpak is installed (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
Antiz96 authored Nov 10, 2023
1 parent 5de4e9f commit a37c510
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/script/arch-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit a37c510

Please sign in to comment.