-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
executable file
·63 lines (48 loc) · 1.67 KB
/
Copy pathuninstall.sh
File metadata and controls
executable file
·63 lines (48 loc) · 1.67 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
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
set -euo pipefail
DAEMON_NAME="kb-autolight"
BIN_DIR="$HOME/.local/bin"
CONFIG_DIR="$HOME/.config/$DAEMON_NAME"
SERVICE_DIR="$HOME/.config/systemd/user"
GREEN='\033[0;32m'
NC='\033[0m'
info() { echo -e "${GREEN}[INFO]${NC} $*"; }
# --- Stop and disable service ---
if systemctl --user is-active "$DAEMON_NAME.service" &>/dev/null; then
info "Stopping $DAEMON_NAME service..."
systemctl --user stop "$DAEMON_NAME.service"
fi
if systemctl --user is-enabled "$DAEMON_NAME.service" &>/dev/null; then
info "Disabling $DAEMON_NAME service..."
systemctl --user disable "$DAEMON_NAME.service"
fi
# --- Remove files ---
if [ -f "$SERVICE_DIR/$DAEMON_NAME.service" ]; then
info "Removing service file..."
rm "$SERVICE_DIR/$DAEMON_NAME.service"
systemctl --user daemon-reload
fi
if [ -f "$BIN_DIR/$DAEMON_NAME.py" ]; then
info "Removing daemon script..."
rm "$BIN_DIR/$DAEMON_NAME.py"
fi
# --- Config removal (ask first) ---
if [ -d "$CONFIG_DIR" ]; then
echo ""
read -rp "Remove config directory ($CONFIG_DIR)? [y/N] " answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
info "Removing config directory..."
rm -rf "$CONFIG_DIR"
else
info "Keeping config directory at $CONFIG_DIR"
fi
fi
# --- Turn off backlight ---
KBD_DEVICE=$(basename "$(ls -d /sys/class/leds/*kbd_backlight 2>/dev/null | head -1)" 2>/dev/null || true)
if [ -n "$KBD_DEVICE" ]; then
info "Turning off keyboard backlight..."
busctl call org.freedesktop.login1 /org/freedesktop/login1/session/auto \
org.freedesktop.login1.Session SetBrightness ssu leds "$KBD_DEVICE" 0 &>/dev/null || true
fi
echo ""
info "Uninstall complete."