-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·54 lines (46 loc) · 1.56 KB
/
uninstall.sh
File metadata and controls
executable file
·54 lines (46 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env bash
# AppBlocker uninstall script
set -euo pipefail
BINARY_NAME="appblocker"
SERVICE_NAME="${BINARY_NAME}.service"
green() { printf '\e[32m✓\e[0m %s\n' "$*"; }
yellow(){ printf '\e[33m→\e[0m %s\n' "$*"; }
# Stop and disable the systemd service.
systemctl --user stop "${SERVICE_NAME}" 2>/dev/null && green "Service stopped." || true
systemctl --user disable "${SERVICE_NAME}" 2>/dev/null && green "Service disabled." || true
SERVICE_PATH="${HOME}/.config/systemd/user/${SERVICE_NAME}"
if [[ -f "${SERVICE_PATH}" ]]; then
rm "${SERVICE_PATH}"
systemctl --user daemon-reload 2>/dev/null || true
green "Service file removed."
fi
# Remove binary.
for dir in "/usr/local/bin" "${HOME}/.local/bin"; do
target="${dir}/${BINARY_NAME}"
if [[ -f "${target}" ]]; then
rm "${target}"
green "Removed binary: ${target}"
fi
done
# Remove desktop entry.
for dir in "/usr/share/applications" "${HOME}/.local/share/applications"; do
desktop="${dir}/${BINARY_NAME}.desktop"
if [[ -f "${desktop}" ]]; then
rm "${desktop}"
update-desktop-database "${dir}" 2>/dev/null || true
green "Removed desktop entry: ${desktop}"
fi
done
# Offer to remove config.
CONFIG_DIR="${HOME}/.config/appblocker"
if [[ -d "${CONFIG_DIR}" ]]; then
read -r -p "Remove config and rules at ${CONFIG_DIR}? [y/N] " answer
if [[ "${answer,,}" == "y" ]]; then
rm -rf "${CONFIG_DIR}"
green "Config removed."
else
yellow "Config kept at ${CONFIG_DIR}"
fi
fi
echo ""
green "AppBlocker uninstalled."