-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-menubar.sh
More file actions
executable file
·81 lines (73 loc) · 2.29 KB
/
Copy pathinstall-menubar.sh
File metadata and controls
executable file
·81 lines (73 loc) · 2.29 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
#!/usr/bin/env bash
# Install a macOS LaunchAgent so the paper-review menubar app starts at login
# and stays alive. Edits the user's ~/Library/LaunchAgents.
#
# Usage:
# bash install-menubar.sh # install + load
# bash install-menubar.sh --uninstall
#
set -euo pipefail
LABEL="com.paper-review.menubar"
PLIST="$HOME/Library/LaunchAgents/$LABEL.plist"
REPO_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_BIN="$REPO_DIR/.venv/bin/paper-review"
LOG_DIR="$REPO_DIR/_logs"
if [[ "${1:-}" == "--uninstall" ]]; then
launchctl unload "$PLIST" 2>/dev/null || true
rm -f "$PLIST"
echo "✓ uninstalled $LABEL"
exit 0
fi
if [[ ! -x "$VENV_BIN" ]]; then
echo "ERROR: $VENV_BIN not found. Run 'uv pip install -e .' first." >&2
exit 1
fi
mkdir -p "$HOME/Library/LaunchAgents" "$LOG_DIR"
# Resolve the directory holding the `claude` CLI so the agent's PATH can find it
CLAUDE_DIR=""
if command -v claude >/dev/null 2>&1; then
CLAUDE_DIR="$(dirname "$(command -v claude)")"
fi
AGENT_PATH="$HOME/.local/bin:$(dirname "$VENV_BIN"):/usr/local/bin:/usr/bin:/bin"
[[ -n "$CLAUDE_DIR" ]] && AGENT_PATH="$CLAUDE_DIR:$AGENT_PATH"
cat > "$PLIST" <<PLISTEOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>$LABEL</string>
<key>ProgramArguments</key>
<array>
<string>$VENV_BIN</string>
<string>menubar</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>$AGENT_PATH</string>
</dict>
<key>StandardOutPath</key>
<string>$LOG_DIR/menubar.out.log</string>
<key>StandardErrorPath</key>
<string>$LOG_DIR/menubar.err.log</string>
<key>ProcessType</key>
<string>Interactive</string>
</dict>
</plist>
PLISTEOF
# Reload
launchctl unload "$PLIST" 2>/dev/null || true
launchctl load "$PLIST"
echo "✓ installed $LABEL"
echo " plist: $PLIST"
echo " The menubar app will start now and at every login."
echo " Quit from the menubar to stop; it won't auto-restart after a clean quit."
echo " Uninstall: bash install-menubar.sh --uninstall"