updated uninstall.sh

This commit is contained in:
JaKooLit
2025-03-11 13:24:35 +09:00
parent bab65fd28d
commit c93101a99e

View File

@@ -32,14 +32,11 @@ printf "\n%.0s" {1..1}
whiptail --title "Arch-Hyprland KooL Dots Uninstall Script" --yesno \ whiptail --title "Arch-Hyprland KooL Dots Uninstall Script" --yesno \
"Hello! This script will uninstall KooL Hyprland packages and configs. "Hello! This script will uninstall KooL Hyprland packages and configs.
You can choose packages and directories you want to remove. You can choose packages and directories you want to remove.
NOTE: This will remove configs from ~/.config NOTE: This will remove configs from ~/.config
WARNING: After uninstallation, your system may become unstable. WARNING: After uninstallation, your system may become unstable.
Shall we Proceed?" 20 80 Shall we Proceed?" 20 80
# Check if the user confirmed to proceed # Check if the user confirmed to proceed
@@ -52,7 +49,7 @@ fi
remove_packages() { remove_packages() {
local selected_packages=($1) local selected_packages=($1)
for package in "${selected_packages[@]}"; do for package in "${selected_packages[@]}"; do
package=$(echo "$package" | tr -d '"') # Remove extra quotes package=$(echo "$package" | tr -d '"')
if pacman -Qi "$package" &> /dev/null; then if pacman -Qi "$package" &> /dev/null; then
echo "Removing package: $package" echo "Removing package: $package"
if ! sudo pacman -Rsc --noconfirm "$package"; then if ! sudo pacman -Rsc --noconfirm "$package"; then
@@ -70,7 +67,7 @@ remove_packages() {
remove_directories() { remove_directories() {
local selected_dirs=($1) local selected_dirs=($1)
for dir in "${selected_dirs[@]}"; do for dir in "${selected_dirs[@]}"; do
dir=$(echo "$dir" | tr -d '"') # Remove extra quotes dir=$(echo "$dir" | tr -d '"')
if [ -d "$HOME/.config/$dir" ]; then if [ -d "$HOME/.config/$dir" ]; then
echo "Removing directory: $HOME/.config/$dir" echo "Removing directory: $HOME/.config/$dir"
if ! rm -rf "$HOME/.config/$dir"; then if ! rm -rf "$HOME/.config/$dir"; then
@@ -157,52 +154,55 @@ directories=(
"wlogout" "wlogout (logout menu) configuration" "off" "wlogout" "wlogout (logout menu) configuration" "off"
) )
# Use whiptail to choose packages to remove # Loop for package selection until user selects something or cancels
package_choices=$(whiptail --title "Select Packages to Uninstall" --checklist \ while true; do
"Select the packages you want to remove\nNOTE: 'SPACEBAR' to select & 'TAB' key to change selection" 35 90 25 \ package_choices=$(whiptail --title "Select Packages to Uninstall" --checklist \
"${packages[@]}" 3>&1 1>&2 2>&3) "Select the packages you want to remove\nNOTE: 'SPACEBAR' to select & 'TAB' key to change selection" 35 90 25 \
"${packages[@]}" 3>&1 1>&2 2>&3)
# Check if the user canceled the operation # Check if the user canceled the operation
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
echo "Operation canceled." echo "$INFO uninstall process canceled."
exit 0 exit 0
fi fi
# Debugging output: Check what was selected # If no packages are selected, ask again
echo "Selected packages: '$package_choices'" # Debugging line if [[ -z "$package_choices" ]]; then
echo "$NOTE No packages selected. Please select at least one package."
else
# Convert the selected package list into an array and clean up quotes
IFS=" " read -r -a selected_packages <<< "$package_choices"
selected_packages=($(echo "${selected_packages[@]}" | tr -d '"'))
echo "Packages to remove: ${selected_packages[@]}"
break
fi
done
# Check if the selected packages are empty or not # Loop for directory selection until user selects something or cancels
if [[ -z "$package_choices" ]]; then while true; do
echo "No packages selected." dir_choices=$(whiptail --title "Select Directories to Remove" --checklist \
else "Select the directories you want to remove\nNOTE: This will remove configs from ~/.config\n\nNOTE: 'SPACEBAR' to select & 'TAB' key to change selection" 28 90 18 \
# Convert the selected package list into an array and clean up quotes "${directories[@]}" 3>&1 1>&2 2>&3)
IFS=" " read -r -a selected_packages <<< "$package_choices"
selected_packages=($(echo "${selected_packages[@]}" | tr -d '"'))
echo "Packages to remove: ${selected_packages[@]}"
fi
# Use whiptail to choose directories to remove # Check if the user canceled the operation
dir_choices=$(whiptail --title "Select Directories to Remove" --checklist \ if [ $? -eq 1 ]; then
"Select the directories you want to remove\nNOTE: This will remove configs from ~/.config\n\nNOTE: 'SPACEBAR' to select & 'TAB' key to change selection" 28 90 18 \ echo "$INFO uninstall process canceled."
"${directories[@]}" 3>&1 1>&2 2>&3) exit 0
fi
# Check if the user canceled the operation echo "Selected directories: '$dir_choices'"
if [ $? -eq 1 ]; then
echo "$INFO uninstall process canceled."
exit 0
fi
echo "Selected directories: '$dir_choices'" # If no directories are selected, ask again
if [[ -z "$dir_choices" ]]; then
# Check if the selected directories are empty or not echo "$NOTE No directories selected. Please select at least one directory."
if [[ -z "$dir_choices" ]]; then else
echo "$NOTE No directories selected." # Convert the selected directories list into an array and clean up quotes
else IFS=" " read -r -a selected_dirs <<< "$dir_choices"
# Convert the selected directories list into an array and clean up quotes selected_dirs=($(echo "${selected_dirs[@]}" | tr -d '"'))
IFS=" " read -r -a selected_dirs <<< "$dir_choices" echo "Directories to remove: ${selected_dirs[@]}"
selected_dirs=($(echo "${selected_dirs[@]}" | tr -d '"')) break
echo "Directories to remove: ${selected_dirs[@]}" fi
fi done
# First confirmation - Warning about potential instability # First confirmation - Warning about potential instability
if ! whiptail --title "Warning" --yesno \ if ! whiptail --title "Warning" --yesno \