VibeNotification的Github仓库:
开发和调试不易,希望小伙伴们帮忙给项目点Star、关注我的帐号呀!感谢感谢!
前言
最近在用 Claude Code/Codex 跑长任务时,我希望他们工作时我可以做点别的事;等回复完成后再给个系统提示,我再过去查看结果。在Play a sound when Codex finishes a prompt / task · Issue #3962 · openai/codex的启示下,我折腾了个小工具——VibeNotification,能在 Claude Code/Codex 回复完成时弹系统通知+响铃。经过一段时间的调试,目前算是可用性比较强了,这里就公开给大家用一下 (~ ̄▽ ̄)~
功能亮点
交互式配置界面
python -m vibe_notification --config
# 会出现友好的交互式配置向导,按回车使用默认值即可
音量控制
可以调节提示音的音量大小:
# 设置音量为 50%
VIBE_NOTIFICATION_SOUND_VOLUME=0.5 python -m vibe_notification
# 通过配置文件设置更持久
多系统声音
支持 5 种系统内置声音,不同操作系统的兼容性如下:
| 声音类型 | Windows | macOS | Linux | 说明 |
| Glass | ⚠️ 映射到 Asterisk | ✅ 原生支持 | ⚠️ 使用默认声音 | 清脆的玻璃声,推荐用于成功提示 |
| Ping | ⚠️ 映射到 Asterisk | ✅ 原生支持 | ⚠️ 使用默认声音 | 清晰的叮声,适合一般通知 |
| Pop | ❌ 不可用 | ✅ 原生支持 | ⚠️ 使用默认声音 | 轻快的弹出声 |
| Tink | ❌ 不可用 | ✅ 原生支持 | ⚠️ 使用默认声音 | 细小的提示音 |
| Basso | ⚠️ 映射到 Exclamation | ✅ 原生支持 | ⚠️ 使用默认声音 | 低沉的警示音,适合错误提示 |
- 配置方式
# 测试不同声音
python -m vibe_notification --sound-name Glass --test # 成功提示音
python -m vibe_notification --sound-name Basso --test # 错误提示音
python -m vibe_notification --sound-name Ping --test # 一般通知音
- 注意事项
- Linux 系统由于发行版差异,所有声音类型都会使用系统默认声音
- Windows 系统由于 API 限制,部分声音类型会映射到相似的系统声音
- 建议根据使用场景选择合适的声音类型,提高识别效率
其它功能
- 智能IDE识别
- 智能项目名识别
- 多语言支持:支持中英文界面自动切换,根据系统语言自动适配。
快速安装
💡 需要 Python 环境
还没有安装 Python?请查看官方文档:
– Python 安装使用指南 – 官方完整的安装说明
– Python 官方下载页面 – 获取最新版本
– Python 中文文档 – 中文版安装指南💻 要求:Python 3.7+(支持 3.7-3.11 版本)
创建python虚拟环境
可选项。不是必须的。直接安装在base环境我觉得没啥问题。
python -m venv venv && source venv/bin/activate
获取项目代码
- 方式一:直接从 GitHub 克隆
git clone https://github.com/huangwb8/VibeNotification.git
cd VibeNotification
pip install -e .
- 方式二:从 PyPI 安装
pip install vibe-notification
首次自检
python -m vibe_notification --test
效果:弹出系统通知 + 播放提示音,如果系统静音或禁用通知,会看到 INFO 日志但无弹窗
配置VibeNotification
Claude Code
Claude Code 的 Stop 钩子在每次回复完成时触发,最适合做即时提醒。把下面片段写进 ~/.claude/settings.json:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "python -m vibe_notification"
}
]
}
]
}
}
Codex
Codex 支持 notify 钩子,把事件 JSON 丢给 VibeNotification 即可。打开 ~/.codex/config.toml,追加:
notify = ["python3", "-m", "vibe_notification"]
VibeNotification的配置文件 & 环境变量速查
默认配置存放在 ~/.config/vibe-notification/config.json,一般用户不需要直接修改。我这边也给了在Shell里进行交互式配置的特性:
# 会出现友好的交互式配置向导,支持中英文
python -m vibe_notification --config
- 完整配置项
{
"enable_sound": true, // 是否播放提示音
"enable_notification": true, // 系统通知开关
"sound_name": "Glass", // 声音类型:Glass/Ping/Pop/Tink/Basso
"sound_volume": 1.0, // 音量:0.0-1.0
"notification_timeout": 10000, // 通知停留时间(毫秒)
"log_level": "INFO", // 日志级别:DEBUG/INFO/WARNING/ERROR
"language": "auto" // 界面语言:auto/zh-CN/en
}
- 环境变量覆盖(优先级更高):
一般来说不推荐。 但反正也支持吧 (~ ̄▽ ̄)~
# 基础控制
VIBE_NOTIFICATION_SOUND=0 # 关闭声音
VIBE_NOTIFICATION_NOTIFY=0 # 关闭弹窗
VIBE_NOTIFICATION_SOUND_VOLUME=0.5 # 音量 50%
VIBE_NOTIFICATION_SOUND_NAME=Ping # 切换声音
# 调试用
VIBE_NOTIFICATION_LOG_LEVEL=DEBUG # 显示详细日志
VIBE_NOTIFICATION_CONFIG_FILE=/path/to/config.json # 使用自定义配置文件
验证流程
python -m vibe_notification --test有弹窗/铃声,说明本地依赖 OK。- 在 Claude Code 回复一次,看控制台是否有
command被触发;没有的话检查settings.json路径和 JSON 括号。 - 在 Codex 里随便跑个工具,结束后应看到通知;如果只剩日志,检查
~/.codex/config.toml是否被其他notify覆盖。 - Linux 桌面看下
notify-send是否可用;macOS 需要通知权限别关掉。
调试技巧
- 开启 DEBUG 模式查看详细信息:
VIBE_NOTIFICATION_LOG_LEVEL=DEBUG python -m vibe_notification --test
- 检查配置是否生效:
python -m vibe_notification --show-config
- 测试不同声音:
for sound in Glass Ping Pop Tink Basso; do
echo "Testing $sound..."
VIBE_NOTIFICATION_SOUND_NAME=$sound python -m vibe_notification --test
done
FAQ
- 静音/勿扰模式:系统把声音吃掉了,别怪 VibeNotification。
- Python 版本:需要 Python 3.7+,旧版本会报依赖错误。
- 权限问题:Windows 记得用 PowerShell 执行,macOS 第一次弹窗要点”允许”。
- 多环境冲突:如果同时开了多个虚拟环境,确认
which python指向安装了 VibeNotification 的那个。 - 通知和声音不同步:1.0.0 版本的已知 bug,升级到 1.0.1 已修复。
- Codex 项目名显示错误:已在新版本中修复,现在能正确识别项目名称。
- Claude Code 会话结束无通知:检查是否正确配置了
SessionEnd钩子。 - Linux 依赖问题:Ubuntu/Debian 需要安装
libnotify-bin:
sudo apt-get install libnotify-bin
进阶用法
批量任务监控
如果你经常运行批量任务,可以创建一个别名:
# 添加到 ~/.bashrc 或 ~/.zshrc
alias vibt='VIBE_NOTIFICATION_LOG_LEVEL=DEBUG python -m vibe_notification --test'
alias vibc='python -m vibe_notification --config'
自动化脚本示例
# run_with_notify.py
import subprocess
import sys
from vibe_notification import send_notification
# 运行命令
result = subprocess.run(sys.argv[1:], capture_output=True, text=True)
# 根据结果发送不同通知
if result.returncode == 0:
send_notification("任务成功", f"{sys.argv[1]} 执行成功")
else:
send_notification("任务失败", f"{sys.argv[1]} 执行失败", sound_name="Basso")
集成到 CI/CD
在 GitHub Actions 或其他 CI/CD 中使用:
- name: Notify completion
if: always()
run: |
pip install vibe-notification
python -m vibe_notification "构建完成: ${{ job.status }}"
小结
现在咱们已经拥有一个功能完善的”AI 助手通知助手”。VibeNotification 不仅解决了基本的提醒需求,还提供了丰富的自定义选项和优雅的使用体验。下次跑Codex/Claude Code长任务,不用盯着屏幕了,直接去其它界面看剧喝菜,爽得一批;等它滴一声、弹窗再回去看看输出结果就行。Gemini CLI因为我自己没用过,所以没有支持。有问题的小伙伴欢迎到 GitHub 仓库 提 Issue 或 PR (~ ̄▽ ̄)~ ;博客评论区留言也没问题!
---------------
完结,撒花!如果您点一下广告,可以养活苯苯😍😍😍