add remove packages functionality

This commit is contained in:
2026-06-03 14:45:23 -06:00
parent cbe7dc938e
commit a9981a11ad
4 changed files with 52 additions and 2 deletions

View File

@@ -25,4 +25,38 @@ install_packages() {
echo "Installing: ${to_install[*]}"
yay -S --noconfirm "${to_install[@]}"
fi
}
}
# Function to remove pacman/AUR packages if installed
remove_packages() {
local packages=("$@")
local to_remove=()
for pkg in "${packages[@]}"; do
if is_installed "$pkg"; then
to_remove+=("$pkg")
fi
done
if [ ${#to_remove[@]} -ne 0 ]; then
echo "Removing: ${to_remove[*]}"
sudo pacman -Rns --noconfirm "${to_remove[@]}"
fi
}
# Function to remove flatpak applications if installed
remove_flatpaks() {
local flatpaks=("$@")
local to_remove=()
for pak in "${flatpaks[@]}"; do
if flatpak list | grep -qi "$pak"; then
to_remove+=("$pak")
fi
done
if [ ${#to_remove[@]} -ne 0 ]; then
echo "Removing flatpaks: ${to_remove[*]}"
flatpak uninstall --noninteractive "${to_remove[@]}"
fi
}