2016-04-23 04:32:43 +00:00
|
|
|
#!/bin/bash
|
2016-04-20 15:48:14 +00:00
|
|
|
# vim: tw=120:
|
2016-04-18 02:36:26 +00:00
|
|
|
|
2016-04-19 15:51:03 +00:00
|
|
|
# This file is part of Background Music.
|
|
|
|
#
|
|
|
|
# Background Music is free software: you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License as
|
|
|
|
# published by the Free Software Foundation, either version 2 of the
|
|
|
|
# License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Background Music is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Background Music. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
#
|
|
|
|
# uninstall.sh
|
|
|
|
#
|
|
|
|
# Copyright © 2016 Nick Jacques
|
2017-06-17 11:22:01 +00:00
|
|
|
# Copyright © 2016, 2017 Kyle Neideck
|
2016-04-19 15:51:03 +00:00
|
|
|
#
|
|
|
|
# Removes BGMApp, BGMDriver and BGMXPCHelper from the system.
|
|
|
|
#
|
|
|
|
|
2016-04-23 04:32:43 +00:00
|
|
|
# Halt on errors.
|
|
|
|
set -e
|
|
|
|
|
2017-06-12 04:38:26 +00:00
|
|
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin; export PATH
|
|
|
|
|
2016-04-18 02:36:26 +00:00
|
|
|
bold=$(tput bold)
|
|
|
|
normal=$(tput sgr0)
|
|
|
|
|
2016-12-31 10:47:09 +00:00
|
|
|
# Warn if running as root.
|
|
|
|
if [[ $(id -u) -eq 0 ]]; then
|
|
|
|
echo "$(tput setaf 11)WARNING$(tput sgr0): This script is not intended to be run as root. Run" \
|
|
|
|
"it normally and it'll sudo when it needs to." >&2
|
|
|
|
echo ""
|
|
|
|
fi
|
|
|
|
|
2017-06-17 11:22:01 +00:00
|
|
|
echo "${bold}You are about to uninstall Background Music.${normal}"
|
2016-04-18 02:36:26 +00:00
|
|
|
echo "Please pause all audio before continuing."
|
|
|
|
echo ""
|
2016-04-19 15:51:03 +00:00
|
|
|
read -p "Continue (y/N)? " user_prompt
|
2016-04-18 02:36:26 +00:00
|
|
|
|
2016-04-19 15:51:03 +00:00
|
|
|
if [ "$user_prompt" == "y" ] || [ "$user_prompt" == "Y" ]; then
|
2017-06-17 11:22:01 +00:00
|
|
|
# Run from the dir containing this script.
|
|
|
|
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
|
|
|
|
|
|
|
if [ -f "BGMApp/BGMApp/_uninstall-non-interactive.sh" ]; then
|
|
|
|
# Running from the source directory.
|
|
|
|
bash "BGMApp/BGMApp/_uninstall-non-interactive.sh"
|
|
|
|
elif [ -f "_uninstall-non-interactive.sh" ]; then
|
|
|
|
# Probably running from Background Music.app/Contents/Resources.
|
|
|
|
bash "_uninstall-non-interactive.sh"
|
2016-04-19 15:51:03 +00:00
|
|
|
else
|
2017-06-17 11:22:01 +00:00
|
|
|
echo "${bold}ERROR: Could not find _uninstall-non-interactive.sh${normal}" >&2
|
|
|
|
exit 1
|
2016-04-18 02:36:26 +00:00
|
|
|
fi
|
|
|
|
|
2016-04-19 14:49:20 +00:00
|
|
|
# Invalidate sudo ticket
|
|
|
|
sudo -k
|
2016-04-18 02:36:26 +00:00
|
|
|
|
2017-04-09 05:44:46 +00:00
|
|
|
# Open System Preferences and go to Sound > Output.
|
2017-06-17 11:22:01 +00:00
|
|
|
osascript -e 'tell application id "com.apple.systempreferences"
|
|
|
|
activate
|
|
|
|
reveal anchor "output" of pane id "com.apple.preference.sound"
|
|
|
|
end tell' >/dev/null || true
|
2016-04-18 02:36:26 +00:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
else
|
|
|
|
echo "Uninstall cancelled."
|
|
|
|
fi
|
2016-04-19 15:51:03 +00:00
|
|
|
|
|
|
|
|