哪位手摸手教教我 "Hook" ?

需求:
使用hook功能,当对话结束或通知时播放音频文件提醒:alarm_clock:我。

在Claude code 设定类似hook后能进行提醒。

当前iflow配置片段:

"hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "sh ~/.iflow/hooks/stop.sh"
          }
        ]
      }
    ],
    "Notification": [
      {
        "matcher": ".*permission.*",
        "hooks": [
          {
            "type": "command",
            "command": "sh ~/.iflow/hooks/notification.sh"
          }
        ]
      }
    ]
  }

脚本比较简单内容就是播放音频:


more ~/.iflow/hooks/notification.sh
#!/bin/bash

afplay /Users/chenweilong/Music/bell/mixkit-flute-mobile-phone-notification-alert-2316.wav

权限+x ,执行可播放。但是对话完没有提示。

一直不理解哪里出问题了。 :thinking:

1 个赞
"hooks": {
    "SessionEnd": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "toast.exe"
          }
        ]
      }
    ],
    "Notification": [
      {
        "matcher": ".*",
        "hooks": [
          {
            "type": "command",
            "command": "toast.exe"
          }
        ]
      }
    ]
  }

我也遇到了相同的问题 SessionEnd 会通知,但是 Notification 不会

2 个赞

所以是不是文档不清晰 ? :grinning_face_with_smiling_eyes:

0.3.13 hook:Notification 生效了。

1 个赞