-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnotify-desktop.sh
More file actions
executable file
·68 lines (61 loc) · 1.99 KB
/
Copy pathnotify-desktop.sh
File metadata and controls
executable file
·68 lines (61 loc) · 1.99 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
#!/bin/bash
# notify-desktop.sh
# Notification hook. Sends a desktop notification when Claude Code needs attention.
# Cross-platform: macOS (osascript), Linux (notify-send), Windows (powershell).
# Exit codes: 0 = success (always non-blocking)
set -euo pipefail
INPUT=$(cat)
# Extract a human-readable title from the notification type, falling back to a default.
NOTIF_TYPE=$(echo "$INPUT" | jq -r '.notification_type // "idle_prompt"')
case "$NOTIF_TYPE" in
permission_prompt)
TITLE="Claude Code - Permission Required"
MESSAGE="Claude Code is asking for your permission."
;;
idle_prompt)
TITLE="Claude Code - Waiting for Input"
MESSAGE="Claude Code has finished and is waiting for your next prompt."
;;
auth_success)
TITLE="Claude Code - Authenticated"
MESSAGE="Claude Code authentication was successful."
;;
elicitation_dialog)
TITLE="Claude Code - Input Needed"
MESSAGE="Claude Code needs additional information from you."
;;
*)
TITLE="Claude Code"
MESSAGE="Claude Code needs your attention."
;;
esac
OS="$(uname -s 2>/dev/null || echo 'Unknown')"
case "$OS" in
Darwin)
# macOS - use osascript
if command -v osascript &>/dev/null; then
osascript -e "display notification \"$MESSAGE\" with title \"$TITLE\"" 2>/dev/null || true
fi
;;
Linux)
# Linux - use notify-send
if command -v notify-send &>/dev/null; then
notify-send "$TITLE" "$MESSAGE" 2>/dev/null || true
else
echo "notify-desktop: notify-send not found; install libnotify-bin" >&2
fi
;;
CYGWIN*|MINGW*|MSYS*|Windows_NT)
# Windows - use PowerShell toast notification
if command -v powershell.exe &>/dev/null; then
powershell.exe -Command \
"[System.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null; \
[System.Windows.Forms.MessageBox]::Show('$MESSAGE', '$TITLE')" \
2>/dev/null || true
fi
;;
*)
echo "notify-desktop: unsupported OS '$OS'" >&2
;;
esac
exit 0