跳转到主要内容

配置任务提示音

设置Claude Code任务完成时的音频提示。

📋 快速配置

配置文件位置

bash
~/.claude/settings.json

基础配置示例

json
{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "afplay /System/Library/Sounds/Glass.aiff"
          }
        ]
      }
    ]
  }
}

🎵 系统提示音命令

macOS

bash
# 推荐音效
"afplay /System/Library/Sounds/Glass.aiff"
"afplay /System/Library/Sounds/Ping.aiff"
"afplay /System/Library/Sounds/Tink.aiff"

Linux

bash
# paplay命令
"paplay /usr/share/sounds/alsa/Front_Left.wav"

# beep命令
"beep -f 800 -l 300"

Windows

bash
# PowerShell蜂鸣
"powershell -c \"[console]::beep(800,300)\""

# 播放wav文件
"powershell -c \"(New-Object Media.SoundPlayer 'C:\\Windows\\Media\\notify.wav').PlaySync()\""

🔧 进阶配置

自定义音频

json
{
  "type": "command",
  "command": "afplay ~/sounds/custom.mp3"
}

多重通知

json
{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "afplay /System/Library/Sounds/Glass.aiff"
          },
          {
            "type": "command",
            "command": "osascript -e 'display notification \"任务完成\" with title \"Claude Code\"'"
          }
        ]
      }
    ]
  }
}

🛠️ 故障排除

测试配置

bash
# 验证音频文件
ls -la /System/Library/Sounds/Glass.aiff

# 手动测试播放
afplay /System/Library/Sounds/Glass.aiff

# 检查JSON格式
cat ~/.claude/settings.json | python -m json.tool

💡 使用建议

  • 选择简短清脆的提示音,避免过长或过于刺耳的音效
  • 可以根据任务类型设置不同的提示音
  • 在安静环境中工作时,考虑降低音量或使用较为柔和的音效

⚠️ 注意事项

  • 配置文件格式必须是有效的JSON
  • 音频文件路径必须存在且有读取权限
  • 不同操作系统的音频播放命令不同,请选择对应的配置

专注于 AI 编程技术分享,助力开发者提升编程效率