add remove packages functionality
This commit is contained in:
36
utils.sh
36
utils.sh
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user