-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_mac.command
More file actions
156 lines (139 loc) · 7.73 KB
/
install_mac.command
File metadata and controls
156 lines (139 loc) · 7.73 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#!/bin/bash
# ─────────────────────────────────────────────────────────────────────────────
# Hotkeys — Mac installer
# Double-click this file to install. Run time: ~5-10 min (model download).
# ─────────────────────────────────────────────────────────────────────────────
set -e
APP_DIR="$HOME/Hotkeys"
REPO_URL="https://github.com/sprawf/hotkeys/archive/refs/heads/main.zip"
VENV="$APP_DIR/venv"
PYTHON="$VENV/bin/python3"
PIP="$VENV/bin/pip"
# Pretty output
info() { echo ""; echo " ▶ $1"; }
success() { echo " ✓ $1"; }
fail() { echo ""; echo " ✗ ERROR: $1"; echo ""; exit 1; }
clear
echo ""
echo " ╔══════════════════════════════════════╗"
echo " ║ Hotkeys — Mac Installer ║"
echo " ╚══════════════════════════════════════╝"
echo ""
# ── 1. Homebrew ───────────────────────────────────────────────────────────────
info "Checking Homebrew..."
if ! command -v brew &>/dev/null; then
info "Installing Homebrew (you may be asked for your Mac password)..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Add brew to PATH for Apple Silicon Macs
eval "$(/opt/homebrew/bin/brew shellenv)" 2>/dev/null || true
eval "$(/usr/local/bin/brew shellenv)" 2>/dev/null || true
fi
success "Homebrew ready"
# ── 2. Python 3.11 ───────────────────────────────────────────────────────────
info "Checking Python 3.11+..."
BREW_PYTHON=""
for v in python@3.12 python@3.11; do
if brew list "$v" &>/dev/null 2>&1 || brew install "$v" &>/dev/null 2>&1; then
BREW_PYTHON="$(brew --prefix "$v")/bin/python3"
break
fi
done
if [ -z "$BREW_PYTHON" ] || [ ! -f "$BREW_PYTHON" ]; then
# Fall back to any python3 in PATH that is 3.10+
if python3 -c "import sys; assert sys.version_info >= (3,10)" &>/dev/null 2>&1; then
BREW_PYTHON="$(which python3)"
else
fail "Could not install Python. Please install Python 3.11 from https://python.org and re-run this installer."
fi
fi
success "Python ready: $($BREW_PYTHON --version)"
# ── 3. Download app ───────────────────────────────────────────────────────────
info "Downloading Hotkeys..."
# Preserve user data (config, history, prompts) stored in Library/Application Support
USER_DATA="$HOME/Library/Application Support/Hotkeys"
if [ -d "$USER_DATA" ]; then
info "Preserving your settings and history..."
fi
# Only wipe code files, never the venv (speeds up reinstall) or user data
# Remove known code dirs/files, leave venv and models intact if present
for item in main.py storage.py engine.py overlay.py library.py settings.py \
history_ui.py dialogs.py theme.py single_instance.py \
core requirements_mac.txt prompts.json assets; do
rm -rf "$APP_DIR/$item" 2>/dev/null || true
done
mkdir -p "$APP_DIR"
TMP_ZIP="$(mktemp /tmp/hotkeys_XXXX.zip)"
curl -L --progress-bar "$REPO_URL" -o "$TMP_ZIP" || fail "Download failed. Check your internet connection."
unzip -q "$TMP_ZIP" -d /tmp/hotkeys_extract
# The zip contains a single top-level folder — move its contents into APP_DIR
EXTRACTED="$(ls -d /tmp/hotkeys_extract/*/)"
cp -r "$EXTRACTED"* "$APP_DIR/"
rm -rf "$TMP_ZIP" /tmp/hotkeys_extract
success "App files ready"
# ── 4. Virtual environment ────────────────────────────────────────────────────
info "Creating Python environment..."
"$BREW_PYTHON" -m venv "$VENV"
"$PIP" install --quiet --upgrade pip
success "Environment created"
# ── 5. Install packages ───────────────────────────────────────────────────────
info "Installing packages (this takes a few minutes)..."
"$PIP" install --quiet -r "$APP_DIR/requirements_mac.txt" || \
fail "Package install failed. Check your internet connection."
success "Packages installed"
# ── 6. Download Whisper models ────────────────────────────────────────────────
info "Downloading speech models (≈600 MB, please wait)..."
"$PYTHON" - <<'PYEOF'
import sys, os
sys.path.insert(0, os.path.expanduser('~/Hotkeys'))
from huggingface_hub import snapshot_download
import os
models_dir = os.path.expanduser('~/Hotkeys/models')
os.makedirs(models_dir, exist_ok=True)
for name, repo in [('base', 'Systran/faster-whisper-base'),
('small', 'Systran/faster-whisper-small')]:
dest = os.path.join(models_dir, name)
if os.path.exists(os.path.join(dest, 'model.bin')):
print(f' {name} model already present, skipping.')
continue
print(f' Downloading {name} model...')
snapshot_download(repo, local_dir=dest, local_dir_use_symlinks=False)
print(f' {name} model done.')
PYEOF
success "Models ready"
# ── 7. Desktop launcher ───────────────────────────────────────────────────────
info "Creating desktop launcher..."
LAUNCHER="$HOME/Desktop/Hotkeys.command"
cat > "$LAUNCHER" <<LAUNCHER
#!/bin/bash
cd "$APP_DIR"
"$PYTHON" main.py
LAUNCHER
chmod +x "$LAUNCHER"
success "Launcher created on Desktop"
# ── 8. Accessibility permission reminder ──────────────────────────────────────
echo ""
echo " ┌─────────────────────────────────────────────────────┐"
echo " │ ONE-TIME SETUP (30 seconds, do this now) │"
echo " │ │"
echo " │ Hotkeys needs permission to listen for your │"
echo " │ keyboard shortcuts (Ctrl+Enter etc.) │"
echo " │ │"
echo " │ 1. Open: System Settings → Privacy & Security │"
echo " │ → Accessibility │"
echo " │ 2. Click the + button │"
echo " │ 3. Add Terminal (or your terminal app) │"
echo " │ 4. Toggle it ON │"
echo " │ │"
echo " │ You only need to do this once. │"
echo " └─────────────────────────────────────────────────────┘"
echo ""
# Open System Settings to the right pane automatically
open "x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility" 2>/dev/null || true
echo ""
echo " ✅ Installation complete!"
echo ""
echo " To launch Hotkeys:"
echo " → Double-click 'Hotkeys.command' on your Desktop"
echo ""
echo " (You can close this window.)"
echo ""