23 lines
829 B
Bash
Executable File
23 lines
829 B
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
|
|
|
|
# Remove packages that were installed as dependencies and are no longer needed
|
|
# (packages something lists as an optional dependency are kept). To keep one
|
|
# you use directly: sudo pacman -D --asexplicit <package>
|
|
mapfile -t ORPHANS < <(pacman -Qtdq 2>/dev/null)
|
|
if (( ${#ORPHANS[@]} > 0 )); then
|
|
echo "Removing packages no longer needed by anything:"
|
|
printf ' %s\n' "${ORPHANS[@]}"
|
|
sudo pacman -Rns --noconfirm "${ORPHANS[@]}" || exit 1
|
|
echo "To get one of these back, reinstall it with: sudo pacman -S <package>"
|
|
fi
|