-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·100 lines (87 loc) · 3.92 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·100 lines (87 loc) · 3.92 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env bash
set -e
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
RED='\033[0;31m'
NC='\033[0m'
ok() { echo -e "${GREEN}[ok]${NC} $1"; }
info() { echo -e "${YELLOW}[..] $1${NC}"; }
err() { echo -e "${RED}[!!] $1${NC}"; exit 1; }
echo ""
echo "╔══════════════════════════════════════╗"
echo "║ window-watcher — installer ║"
echo "╚══════════════════════════════════════╝"
echo ""
# 1. Check dependencies
info "Checking dependencies..."
for cmd in wmctrl xprop; do
if ! command -v "$cmd" &>/dev/null; then
err "'$cmd' is not installed. Please install it with your package manager (e.g. apt, dnf, pacman)."
fi
ok "$cmd available"
done
# 2. Check X11 session
if [[ "$XDG_SESSION_TYPE" == "wayland" ]]; then
echo ""
echo -e "${YELLOW}[warn] Wayland session detected.${NC}"
echo " wmctrl works via XWayland on Ubuntu 22.04/24.04."
echo " If you see errors, verify that XWayland is active."
echo ""
fi
# 3. Install the script
info "Installing window-watcher.sh..."
mkdir -p "$HOME/.local/bin"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cp "$SCRIPT_DIR/window-watcher.sh" "$HOME/.local/bin/window-watcher.sh"
chmod +x "$HOME/.local/bin/window-watcher.sh"
ok "window-watcher.sh installed at ~/.local/bin/"
cp "$SCRIPT_DIR/ww-open" "$HOME/.local/bin/ww-open"
chmod +x "$HOME/.local/bin/ww-open"
ok "ww-open installed at ~/.local/bin/"
if [[ -f "$SCRIPT_DIR/config.sh" ]]; then
cp "$SCRIPT_DIR/config.sh" "$HOME/.local/bin/config.sh"
ok "config.sh installed at ~/.local/bin/"
elif [[ ! -f "$HOME/.local/bin/config.sh" ]]; then
echo ""
info "No config.sh found. Copy config.example.sh to config.sh and edit it:"
echo " cp config.example.sh config.sh"
echo ""
fi
# 4. Set ww-open as default URL handler
info "Setting ww-open as default URL handler..."
mkdir -p "$HOME/.local/share/applications"
cp "$SCRIPT_DIR/ww-open.desktop" "$HOME/.local/share/applications/ww-open.desktop"
xdg-settings set default-web-browser ww-open.desktop 2>/dev/null && \
ok "ww-open set as default URL handler" || \
info "could not set default — run: xdg-settings set default-web-browser ww-open.desktop"
# 5. Install systemd service
info "Installing systemd service..."
mkdir -p "$HOME/.config/systemd/user"
cp "$SCRIPT_DIR/window-watcher.service" "$HOME/.config/systemd/user/window-watcher.service"
ok "service installed at ~/.config/systemd/user/"
# 5. Enable and start
info "Enabling service..."
systemctl --user daemon-reload
systemctl --user enable window-watcher.service
systemctl --user restart window-watcher.service
sleep 1
if systemctl --user is-active --quiet window-watcher.service; then
ok "service running"
else
err "service did not start — check: journalctl --user -u window-watcher -n 20"
fi
echo ""
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ Installation complete ║"
echo "╠═══════════════════════════════════════════════════════╣"
echo "║ View logs: journalctl --user -u window-watcher -f ║"
echo "║ Stop: systemctl --user stop window-watcher ║"
echo "║ Uninstall: bash uninstall.sh ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo ""
echo " To add more apps edit WATCH_CLASSES in:"
echo " ~/.local/bin/window-watcher.sh"
echo ""
echo " To find the WM_CLASS of any window:"
echo " xprop | grep WM_CLASS (then click on the window)"
echo ""