Make uninstall.sh script interactive

This commit is contained in:
Serhii Yeremenko 2023-10-28 12:11:02 +03:00
parent efbba7edaa
commit 0f363f30b5
No known key found for this signature in database
GPG key ID: AB6D54C1C16D2507
2 changed files with 37 additions and 5 deletions

View file

@ -106,6 +106,8 @@ wget -qO- https://git.io/papirus-icon-theme-install | env DESTDIR="/usr/local/sh
#### Uninstall
Use this interactive script to completely remove Papirus icon theme on your system.
```
wget -qO- https://git.io/papirus-icon-theme-uninstall | sh
```

View file

@ -24,12 +24,42 @@ cat <<- EOF
EOF
_rm_icon_theme() {
test -d "$1" || return 0
echo "Removing '$1'..." >&2
if [ -w "$1" ]; then
rm -rf "$1"
else
if command -v sudo >/dev/null; then
sudo rm -rf "$1"
elif command -v doas >/dev/null; then
doas rm -rf "$1"
else
echo "Failed to remove '$1'. Please run the script with root permission." >&2
fi
fi
}
_yes_no() {
printf '%s [Y/n]: ' "$*"
read -r yes_no </dev/tty # don't read from stdin
case "$yes_no" in
[Yy]|'') return 0 ;;
[Nn]|*) return 1 ;;
esac
}
echo "=> Removing $gh_desc ..."
for d in "$HOME/.icons" "$HOME/.local/share/icons" "/usr/local/share/icons" "/usr/share/icons"; do
for i in ePapirus ePapirus-Dark Papirus Papirus-Adapta Papirus-Adapta-Nokto Papirus-Dark Papirus-Light; do
rm -rf "$HOME/.icons/$i"
rm -rf "$HOME/.local/share/icons/$i"
sudo rm -rf "/usr/local/share/icons/$i"
sudo rm -rf "/usr/share/icons/$i"
[ -d "$d/$i" ] || continue
if _yes_no "Do you want to remove '$i' from '$d'"; then
_rm_icon_theme "$d/$i"
fi
done
done
echo "=> Done!"