#!/bin/bash

if [ ! -t 0 ]; then
    notify-send -t 10000 "Error" "This script must be run from such as a terminal emulator (not a file manager)."
    exit 1
fi

sudo rm -r /opt/share/shule
sudo rm /opt/bin/shule
if [ -z "$(ls -A /opt/share)" ]; then
   sudo rm -r /opt/share
else
   echo "/opt/share has other items in it. Therefore, the uninstaller will not delete it."
fi
if [ -z "$(ls -A /opt/bin)" ]; then
   sudo rm -r /opt/bin
else
   echo "/opt/bin has other items in it. Therefore, the uninstaller will not delete it."
fi
sudo rm -r /opt/shule
echo "Removing /opt/shule"
sudo rm /usr/share/applications/Shule.desktop
echo "Removing /usr/share/applications/Shule.desktop"
for d in /home/*; do
    sudo rm -r "$d/.local/share/Shule/" 2> /dev/null
    echo "If it exists, removing "$d"/.local/share/Shule"
done
sudo update-alternatives --remove-all shule
echo "MIME types not changed. You’ll have to change those back to normal manually until this uninstaller is updated."
