29 lines
1.2 KiB
Bash
Executable File
29 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
echo "Removing unused Flatpak runtimes..."
|
|
sudo flatpak uninstall --system --unused -y --noninteractive
|
|
flatpak uninstall --user --unused -y --noninteractive
|
|
|
|
if command -v paccache &>/dev/null; then
|
|
echo "Trimming pacman package cache..."
|
|
sudo paccache -rk2
|
|
sudo paccache -ruk0
|
|
fi
|
|
|
|
# Offer to remove packages that were installed as dependencies and are no
|
|
# longer needed (packages something lists as an optional dependency are kept).
|
|
# Ask first: one may be something you use directly. Without a terminal to ask
|
|
# on, keep them. To keep one for good: sudo pacman -D --asexplicit <package>
|
|
mapfile -t ORPHANS < <(pacman -Qtdq 2>/dev/null)
|
|
if (( ${#ORPHANS[@]} > 0 )); then
|
|
echo "These packages were installed for something else, and nothing needs them any more:"
|
|
printf ' %s\n' "${ORPHANS[@]}"
|
|
if { : < /dev/tty; } 2> /dev/null && read -rp "Remove them? [y/N] " answer < /dev/tty \
|
|
&& [[ "$answer" == [yY]* ]]; then
|
|
sudo pacman -Rns --noconfirm "${ORPHANS[@]}" || exit 1
|
|
echo "To get one of these back, reinstall it with: sudo pacman -S <package>"
|
|
else
|
|
echo "Kept them. To keep one for good, so you're not asked again: sudo pacman -D --asexplicit <package>"
|
|
fi
|
|
fi
|