#!/usr/bin/sh

sudo echo "Authenticated as root" || exit

if paru -Syu --noconfirm; then
    echo "UPDATE SUCCEDEED"
else
    echo "UPDATE FAILED"
    exit 1
fi


printf "\n=== REMOVE UNUSED PACKAGES ==========================================\n"

# shellcheck disable=SC2046
sudo pacman -Rns --noconfirm $(pacman -Qtdq)

printf "\n=== FLATPAK UPDATE ==================================================\n"

flatpak update -y

printf "\n=== RUN PACDIFF =====================================================\n"

if sudo pacdiff; then
    echo "PACDIFF SUCCEDEED"
else
    echo "PACDIFF FAILED"
    exit 1
fi
#if sudo checkservices; then
#    echo "CHECKSERVICES SUCCEDEED"
#else
#    echo "CHECKSERVICES FAILED"
#    exit 1
#fi

printf "\n\n\n\n=== DONE ============================================================\n"