#!/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 "###############################################################################"
echo "###                      WRITTEN FOR THE ARCOPRO ISO                       ####"
echo "###          SCRIPT TO REMOVE THE MOST OF THE ARCOLINUX PACKAGES           ####"
echo "###          GOAL - GET AS CLOSE AS POSSIBLE TO A PRISTINE ARCH            ####"
echo "###############################################################################"
tput sgr0
echo
# use this check - sudo pacman -Rns $(pacman -Qq | grep 'arcolinux' | grep -v 'arcolinux-mirrorlist-git\|arcolinux-keyring')

packages=(arcolinux-alacritty-git arcolinux-arc-dawn-git arcolinux-desktop-trasher-git arcolinux-desktop-trasher-dev-git
	arcolinux-grub-theme-vimix-git arcolinux-grub-theme-vimix-dev-git arcolinux-gtk-surfn-arc-git arcolinux-neofetch-git
	arcolinux-paru-git arcolinux-sddm-simplicty-git arcolinux-system-config-git arcolinux-system-config-dev-git
	arcolinuxd-system-config-git arcolinuxd-system-config-dev-git arcolinux-systemd-services-git
	arcolinux-wallpapers-git arcolinux-welcome-app-git arcolinux-welcome-app-dev-git arcolinuxd-welcome-app-git arcolinuxd-welcome-app-dev-git
	arconet-variety-config arcopro-wallpapers
	alacritty arandr arc-gtk-theme bat bibata-cursor-theme-bin archlinux-tweak-tool-git dex 
	btop duf downgrade expac hw-probe edid-decode-git edu-surfn-numixs-blue-git feh libadwaita-without-adwaita-git
	micro most neofetch numlockx ripgrep sardi-icons sofirem-git surfn-icons-git the_silver_searcher variety vimix-cursors
	yad os-prober hardinfo2)

echo "All these packages will be removed. Any configs in your home directory must be removed by you."
echo "List of Packages:"
for pkg in "${packages[@]}"; do
    echo "- $pkg"
done
echo "Total number of packages: ${#packages[@]}"


# Prompt for confirmation
read -p "Are you certain you want to remove all these packages? Type y/Y to confirm: " -n 1 -r

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


	num_packages=${#packages[@]}
	echo "#####################################################################"
	echo "Number of packages: $num_packages"  # Corrected variable name
	echo "#####################################################################"

	count=0  # Initialize count

	for name in "${packages[@]}"; do
		if pacman -Q $name &> /dev/null; then
		  ((count++))  # Increment count
		  echo
		  tput setaf 2  # Set color to green
		  echo "#####################################################################"
		  echo "Removing nr $count: $name of $num_packages packages"
		  echo "#####################################################################"
		  tput sgr0  # Reset text formatting to default
		  echo

		  # Confirmation message added for clarity, even with --noconfirm
		  echo "Proceeding to remove $name without further confirmation..."
		  sudo pacman -Rns --noconfirm $name
		  echo
		fi
	done

else
	echo "#####################################################################"
	echo "Operation cancelled"
	echo "#####################################################################"
fi
echo "###############################################################################"
echo "###                DONE - YOU CAN CLOSE THIS WINDOW                        ####"
echo "###############################################################################"
