#!/bin/bash
#set -e
##################################################################################################################
# Author    : Erik Dubois
# Website   : https://www.erikdubois.be
# Website   : https://www.alci.online
# Website   : https://www.arcolinux.info
# Website   : https://www.arcolinux.com
# Website   : https://www.arcolinuxd.com
# Website   : https://www.arcolinuxb.com
# Website   : https://www.arcolinuxiso.com
# Website   : https://www.arcolinuxforum.com
##################################################################################################################
#
#   DO NOT JUST RUN THIS. EXAMINE AND JUDGE. RUN AT YOUR OWN RISK.
#
##################################################################################################################
#tput setaf 0 = black 
#tput setaf 1 = red 
#tput setaf 2 = green
#tput setaf 3 = yellow 
#tput setaf 4 = dark blue 
#tput setaf 5 = purple
#tput setaf 6 = cyan 
#tput setaf 7 = gray 
#tput setaf 8 = light blue
##################################################################################################################

tput setaf 1;
echo "###############################################################################"
echo "###                     SCRIPT TO REMOVE ALL CONKY RELATED APPS            ####"
echo "###############################################################################"
tput sgr0
echo "This script will remove all the conky releated apps"
read -p "Are you sure you want to proceed? (Y/y) " response

if [[ $response =~ ^[Yy]$ ]]; then

    # Array of packages to check
    packages=("conky-lua-archers" "arcolinux-conky-collection-git" "arcolinux-conky-collection-plasma-git")  

    # Function to check if a package is installed
    is_package_installed() {
        if pacman -Q "$1" &> /dev/null; then
            echo "Package $1 is installed."
            return 0  # Success
        else
            echo "Package $1 is not installed."
            return 1  # Failure
        fi
    }

    # Iterate over each package in the array
    for package in "${packages[@]}"; do
        if is_package_installed "$package"; then
            echo "Removing $package..."
            sudo pacman -Rns "$package" --noconfirm
        else
            echo "$package is not installed, no need to remove."
        fi
        echo
        echo "########################"
        echo "Double checking $package"
        echo "########################"
        echo
        if ! is_package_installed "$package"; then
            echo "$package is not installed!"
        else
            echo "$package is still installed. Check manually why not."
        fi
    done

else
    echo "####################################"
    echo "Operation canceled by user."
    echo "####################################"

fi

echo
echo "###############################################################################"
echo "###                DONE - YOU CAN CLOSE THIS WINDOW                        ####"
echo "###############################################################################"
