Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:44:22 +08:00
commit 3413c7065f
5 changed files with 117 additions and 0 deletions

25
hooks/hooks.json Normal file
View File

@@ -0,0 +1,25 @@
{
"description": "Audio feedback when Claude finishes responding and sends notifications",
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/play-sound.sh\" --stop"
}
]
}
],
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "bash \"${CLAUDE_PLUGIN_ROOT}/hooks/play-sound.sh\" --notification"
}
]
}
]
}
}

28
hooks/play-sound.sh Normal file
View File

@@ -0,0 +1,28 @@
#!/usr/bin/env bash
# shellcheck shell=bash
set -euo pipefail
# Check if hook is disabled via environment variable
if [ "${CC_HANDBOOK_SOUNDS_DISABLE_HOOKS:-false}" = "true" ]; then
exit 0
fi
# Parse hook type argument
hook_type="${1:-stop}"
# Select sound file based on hook type
if [ "$hook_type" = "--stop" ]; then
sound_file="${CC_HANDBOOK_STOP_SOUNDS_FILE:-C:/Windows/Media/notify.wav}"
elif [ "$hook_type" = "--notification" ]; then
sound_file="${CC_HANDBOOK_NOTIFICATION_SOUNDS_FILE:-C:/Windows/Media/Windows Exclamation.wav}"
else
# Fallback for backward compatibility
sound_file="${CC_HANDBOOK_SOUNDS_FILE:-C:/Windows/Media/notify.wav}"
fi
# Play sound using PowerShell with -NoProfile to avoid oh-my-posh conflicts
# Use -NonInteractive to prevent any prompts
# Run in background to not block Claude
powershell -NoProfile -NonInteractive -Command "(New-Object Media.SoundPlayer '$sound_file').PlaySync();" &
exit 0