Skip to content

Instantly share code, notes, and snippets.

@regenrek
Last active October 31, 2025 20:04
Show Gist options
  • Save regenrek/42c3bd8931ccb46099715bd04429b919 to your computer and use it in GitHub Desktop.
Save regenrek/42c3bd8931ccb46099715bd04429b919 to your computer and use it in GitHub Desktop.

GPT Codex Sound Notification

hooks/notify.sh

#!/usr/bin/env bash
payload="${1:-$(cat)}"

DEFAULT_CODEX_SOUND="<your_sound_here.wav>"
# Set CODEX_CUSTOM_SOUND in your shell config (e.g. ~/.zshrc;~/.bashrc;...) to override the alert path.
CODEX_CUSTOM_SOUND="${CODEX_CUSTOM_SOUND:-$DEFAULT_CODEX_SOUND}"

if command -v jq >/dev/null 2>&1; then
  notification_type=$(printf '%s' "$payload" | jq -r '.type // empty')

  case "$notification_type" in
    "agent-turn-complete")
      afplay "$CODEX_CUSTOM_SOUND" 2>/dev/null
      
      ;;
    *)
      ;;
  esac
else
  afplay "$CODEX_CUSTOM_SOUND" 2>/dev/null
fi

~/.codex/config.toml

Add this to your codex config

notify = ["/Users/<YOUR_USER>/.codex/hooks/notify.sh"]
tui.notifications = true

Make notify execeutable

chmod +x notify.sh
@regenrek
Copy link
Author

regenrek commented Oct 31, 2025

Be sure that you have the full path in the .codex/config.toml

notify = ["/Users/<YOUR_USER>/.codex/hooks/notify.sh"]

And be sure to set the full path to your .wav file

DEFAULT_CODEX_SOUND="/Users/kregenrek/projects/sounds/icq.wav"

@ultramathi
Copy link

ultramathi commented Oct 31, 2025

Hey @regenrek

Here's my updated file of both tell me where it is wrong

config.toml

notify = ["/Users/mathivanan/.codex/hooks/notify.sh"]
tui.notifications = true

notify.sh

#!/usr/bin/env bash
payload="${1:-$(cat)}"

DEFAULT_CODEX_SOUND="/Users/mathivanan/Music/codexnotification/wowcongratulation.wav"
# Set CODEX_CUSTOM_SOUND in your shell config (e.g. ~/.zshrc;~/.bashrc;...) to override the alert path.
CODEX_CUSTOM_SOUND="${CODEX_CUSTOM_SOUND:-$DEFAULT_CODEX_SOUND}"

if command -v jq >/dev/null 2>&1; then
  notification_type=$(printf '%s' "$payload" | jq -r '.type // empty')

  case "$notification_type" in
    "agent-turn-complete")
      afplay "$CODEX_CUSTOM_SOUND" 2>/dev/null
      
      ;;
    *)
      ;;
  esac
else
  afplay "$CODEX_CUSTOM_SOUND" 2>/dev/null
fi

@regenrek
Copy link
Author

@ultramathi your script is correct (please format it next time so its easier).

can you please make the notify executable.

chmod +x notify.sh

@ultramathi
Copy link

Hey @regenrek Sure,
Yup I did made the notify executable, still no luck :(

@ultramathi
Copy link

Hey @regenrek I found the solution, wow the solution is very simple and I'm not aware of
The notify hook should be placed on TOP 🤦
I was wrong, I placed at bottom, thats the issue

Now working like Charm, Thanks much mate

@seagreen
Copy link

The notify hook should be placed on TOP 🤦

Verified. I added this line to the bottom of the TOML file, and it didn't work:

notify = ["/Users/<YOUR_USER>/.codex/hooks/notify.sh"]
tui.notifications = true

Moved to the top and it worked fine.

@regenrek
Copy link
Author

@ultramathi i tested your script. it works at my end.

@seagreen has maybe a solution for you.

Yes please put don't put it inside/below any [...] brackets.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment