-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtoggle_server_mode.sh
More file actions
executable file
·44 lines (36 loc) · 1.15 KB
/
toggle_server_mode.sh
File metadata and controls
executable file
·44 lines (36 loc) · 1.15 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
#!/usr/bin/env bash
# toggle_server_mode.sh - Toggle between CLI and Server mode
# Updates config.toml and restarts the daemon
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CONFIG_FILE="$SCRIPT_DIR/config.toml"
if [ ! -f "$CONFIG_FILE" ]; then
notify-send "Whisper Mode" "Config file not found: $CONFIG_FILE" -u critical -t 2000
exit 1
fi
# Get current mode from config
CURRENT_MODE=$(python3 -c "
from config_loader import load_config
c = load_config('$SCRIPT_DIR/config.toml')
print(c.daemon.mode)
" 2>/dev/null || echo "cli")
if [ "$CURRENT_MODE" = "server" ]; then
# Switch to CLI mode
sed -i 's/^mode = "server"/mode = "cli"/' "$CONFIG_FILE"
NEW_MODE="CLI"
ICON="●"
else
# Switch to Server mode
sed -i 's/^mode = "cli"/mode = "server"/' "$CONFIG_FILE"
NEW_MODE="Server"
ICON="◆"
fi
# Restart daemon
systemctl --user daemon-reload
systemctl --user restart whisper.service
sleep 1
if systemctl --user is-active --quiet whisper.service; then
notify-send "Whisper Mode" "$ICON Switched to $NEW_MODE mode" -t 2000
else
notify-send "Whisper Mode" "Failed to restart daemon" -u critical -t 3000
fi