PaperWM/uninstall.sh
Ayla Ounce 9e15aa2de5
extend uninstall.sh to handle non-linked installs (#312)
Currently uninstall.sh fails if run on an installation copied or cloned
directly into the extensions directory. This change updates it to check
whether the install is link-based or direct and handle each case
appropriately. Due to the potential danger of a recursive removal, it
prompts the user for confirmation before removing direct installs.
2020-06-05 21:21:33 +02:00

31 lines
810 B
Bash
Executable File

#!/usr/bin/env bash
# NOTE: gnome-extensions uninstall will delete all files in the linked directory
REPO="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [[ -L "$REPO" ]]; then
REPO=`readlink --canonicalize "$REPO"`
fi
UUID=paperwm@hedning:matrix.org
if type gnome-extensions > /dev/null; then
gnome-extensions disable "$UUID"
else
gnome-shell-extension-tool --disable="$UUID"
fi
EXT_DIR=${XDG_DATA_HOME:-$HOME/.local/share}/gnome-shell/extensions
EXT=$EXT_DIR/$UUID
LINK=`readlink --canonicalize "$EXT"`
if [[ "$LINK" != "$REPO" ]]; then
echo "$EXT" does not link to "$REPO", refusing to remove
exit 1
fi
if [ -L "$EXT" ]; then
rm "$EXT"
else
read -p "Remove $EXT? (y/N): " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
rm -rf $EXT
fi
fi