forked from FlorianBruniaux/claude-code-ultimate-guide
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.sh
More file actions
executable file
·62 lines (49 loc) · 1.74 KB
/
notification.sh
File metadata and controls
executable file
·62 lines (49 loc) · 1.74 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
#!/bin/bash
# Hook: Notification - macOS alerts with contextual sounds
# Plays different sound based on notification type
#
# Place in: .claude/hooks/notification.sh
# Register in: .claude/settings.json under Notification event
#
# Note: macOS only - requires afplay and osascript
set -e
# Read JSON from stdin
INPUT=$(cat)
# Extract message and title
MESSAGE=$(echo "$INPUT" | jq -r '.message // "Claude Code Notification"')
TITLE=$(echo "$INPUT" | jq -r '.title // "Claude Code"')
# Select sound based on context
select_sound() {
local msg="$1"
local msg_lower=$(echo "$msg" | tr '[:upper:]' '[:lower:]')
# Success / Completion
if echo "$msg_lower" | grep -qE "(completed|terminé|fini|done|success|réussi|validé|finished)"; then
echo "/System/Library/Sounds/Hero.aiff"
return
fi
# Error / Failure
if echo "$msg_lower" | grep -qE "(error|erreur|failed|échec|échoué|problem|problème|failure)"; then
echo "/System/Library/Sounds/Basso.aiff"
return
fi
# Waiting / Permission
if echo "$msg_lower" | grep -qE "(waiting|attente|permission|approval|input|question|prompt)"; then
echo "/System/Library/Sounds/Submarine.aiff"
return
fi
# Warning / Attention
if echo "$msg_lower" | grep -qE "(warning|attention|caution|alert|avertissement)"; then
echo "/System/Library/Sounds/Sosumi.aiff"
return
fi
# Default
echo "/System/Library/Sounds/Ping.aiff"
}
SOUND_FILE=$(select_sound "$MESSAGE")
# Play sound (in background to avoid blocking)
if [[ -f "$SOUND_FILE" ]]; then
afplay "$SOUND_FILE" &
fi
# Display macOS notification
osascript -e "display notification \"$MESSAGE\" with title \"$TITLE\" sound name \"\"" 2>/dev/null || true
exit 0