diff --git a/v2/arch-full.sh b/v2/arch-full.sh index bc3622c..f1c3360 100755 --- a/v2/arch-full.sh +++ b/v2/arch-full.sh @@ -39,7 +39,26 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ########################## install_packages() { sudo pacman -Sy; sudo pacman -S --noconfirm --needed "$@"; } is_package_installed() { pacman -Qi "$@" &>/dev/null; } -remove_packages() { sudo pacman -Rs --noconfirm "$@"; } +remove_packages() { + local packages_to_remove=() + + # 1. Identify which packages are actually installed + for pkg in "$@"; do + if is_package_installed "$pkg"; then + packages_to_remove+=("$pkg") + else + say_gray "Package '$pkg' not found. Skipping removal." + fi + done + + # 2. Only run pacman if there are packages to remove + if [ ${#packages_to_remove[@]} -gt 0 ]; then + say_cyan "Removing packages: ${packages_to_remove[*]}" + sudo pacman -Rs --noconfirm "${packages_to_remove[@]}" || true + else + say_gray "No packages to remove from the list." + fi +} say_yellow "Starting full setup..." diff --git a/v2/arch-hyprland.sh b/v2/arch-hyprland.sh index 0861dfd..c377dac 100755 --- a/v2/arch-hyprland.sh +++ b/v2/arch-hyprland.sh @@ -39,7 +39,26 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" ########################## install_packages() { sudo pacman -Sy; sudo pacman -S --noconfirm --needed "$@"; } is_package_installed() { pacman -Qi "$@" &>/dev/null; } -remove_packages() { sudo pacman -Rs --noconfirm "$@"; } +remove_packages() { + local packages_to_remove=() + + # 1. Identify which packages are actually installed + for pkg in "$@"; do + if is_package_installed "$pkg"; then + packages_to_remove+=("$pkg") + else + say_gray "Package '$pkg' not found. Skipping removal." + fi + done + + # 2. Only run pacman if there are packages to remove + if [ ${#packages_to_remove[@]} -gt 0 ]; then + say_cyan "Removing packages: ${packages_to_remove[*]}" + sudo pacman -Rs --noconfirm "${packages_to_remove[@]}" || true + else + say_gray "No packages to remove from the list." + fi +} detect_de() { if command -v xfce4-session >/dev/null 2>&1; then diff --git a/v2/arch-xfce.sh b/v2/arch-xfce.sh index 353f70a..fc5096d 100755 --- a/v2/arch-xfce.sh +++ b/v2/arch-xfce.sh @@ -38,8 +38,27 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Helper functions ########################## install_packages() { sudo pacman -S --noconfirm --needed "$@"; } -remove_packages() { sudo pacman -Rs --noconfirm "$@"; } is_package_installed() { pacman -Qi "$@" &>/dev/null; } +remove_packages() { + local packages_to_remove=() + + # 1. Identify which packages are actually installed + for pkg in "$@"; do + if is_package_installed "$pkg"; then + packages_to_remove+=("$pkg") + else + say_gray "Package '$pkg' not found. Skipping removal." + fi + done + + # 2. Only run pacman if there are packages to remove + if [ ${#packages_to_remove[@]} -gt 0 ]; then + say_cyan "Removing packages: ${packages_to_remove[*]}" + sudo pacman -Rs --noconfirm "${packages_to_remove[@]}" || true + else + say_gray "No packages to remove from the list." + fi +} detect_de() { if command -v xfce4-session >/dev/null 2>&1; then diff --git a/v2/arch.sh b/v2/arch.sh index 13e882a..fc179be 100755 --- a/v2/arch.sh +++ b/v2/arch.sh @@ -43,8 +43,27 @@ say_gray "DE: $DE, TWM: $TWM, Install Level: $INSTALL_LEVEL" # Helper functions ########################## install_packages() { sudo pacman -S --noconfirm --needed "$@"; } -remove_packages() { sudo pacman -Rs --noconfirm "$@"; } is_package_installed() { pacman -Qi "$@" &>/dev/null; } +remove_packages() { + local packages_to_remove=() + + # 1. Identify which packages are actually installed + for pkg in "$@"; do + if is_package_installed "$pkg"; then + packages_to_remove+=("$pkg") + else + say_gray "Package '$pkg' not found. Skipping removal." + fi + done + + # 2. Only run pacman if there are packages to remove + if [ ${#packages_to_remove[@]} -gt 0 ]; then + say_cyan "Removing packages: ${packages_to_remove[*]}" + sudo pacman -Rs --noconfirm "${packages_to_remove[@]}" || true + else + say_gray "No packages to remove from the list." + fi +} ########################## # 0. Ensure base is ready for installation