All guides

Get a notification or sound when Codex CLI finishes

Updated 17 November 2026

Set notifications = true under [tui] in ~/.codex/config.toml for built-in terminal notifications, which by default fire when the terminal is not focused. For a macOS notification or a sound from any terminal, set notify to a script of your own; Codex runs it each time a turn completes.

Codex CLI has two ways to tell you it is done. One is built into its terminal interface and depends on what your terminal supports. The other runs any program you like when a turn completes, which works everywhere. Both are a few lines in ~/.codex/config.toml.

The settings are described in the Codex advanced configuration docs and its configuration reference.

How do I turn on the built-in notifications?

Add this to ~/.codex/config.toml:

[tui]
notifications = true

tui.notifications takes either a boolean or a list of event types. The docs give two example types, agent-turn-complete and approval-requested, so you can limit it to the ones you care about:

[tui]
notifications = ["agent-turn-complete", "approval-requested"]

Two related keys control how and when they appear:

Key Values Default What it does
tui.notification_method auto, osc9, bel auto How the notification is sent to the terminal
tui.notification_condition unfocused, always unfocused Whether it fires only when the terminal is not focused

In auto, Codex uses OSC 9 when the terminal appears to support it and falls back to the bell character otherwise. So in a terminal that understands OSC 9 you get a desktop notification, and elsewhere you get whatever your terminal does with a bell. If you hear and see nothing, check that the terminal app is allowed to send notifications in macOS System Settings, and that its bell is not muted.

Because the default condition is unfocused, you will not get a notification while you are looking at the Codex window. Set it to always if you want one regardless:

[tui]
notifications = true
notification_condition = "always"

How do I get a macOS notification from any terminal?

Use notify. It names a program that Codex runs when it emits a supported event, and passes it one JSON argument.

  1. Save this as ~/.codex/notify.py. It is a minimal script written for this guide; the docs have a longer example that uses terminal-notifier.

    #!/usr/bin/env python3
    import json
    import subprocess
    import sys
    
    payload = json.loads(sys.argv[1])
    if payload.get("type") != "agent-turn-complete":
        sys.exit(0)
    
    subprocess.run([
        "osascript", "-e",
        'display notification "Codex finished a turn" with title "Codex"',
    ])
  2. Point Codex at it. notify is a top-level key, so put it above any [section] headers in ~/.codex/config.toml:

    notify = ["python3", "/Users/you/.codex/notify.py"]

    Use the full path to the file on your Mac.

  3. Start a new Codex session and let a turn finish.

If nothing appears, run osascript -e 'display notification "test"' in Terminal once, then open System Settings > Notifications, find Script Editor and turn on Allow Notifications. osascript sends its notifications through Script Editor, and macOS does not ask you for that permission.

How do I play a sound instead?

Swap the subprocess.run call for afplay, which ships with macOS:

subprocess.run(["afplay", "/System/Library/Sounds/Glass.aiff"])

Or keep both lines and get a banner with a sound.

What does Codex pass to the script?

One JSON object as the first argument. The docs list these fields:

Field Contents
type The event type, currently agent-turn-complete
thread-id The session identifier
turn-id The turn identifier
cwd The working directory
input-messages The user messages that led to the turn
last-assistant-message The text of the last assistant message

That is enough to make the notification say something useful. For example, read payload.get("cwd") and put the folder name in the title, so that with two Codex sessions open you can tell which one finished. Be careful about putting last-assistant-message straight into an osascript string; quotes in the text will break the command unless you escape them.

Which one tells me Codex needs approval?

This is the gap. According to the docs, notify currently supports only agent-turn-complete. It does not run when Codex stops to ask for approval.

For approvals you have two options:

  • Include approval-requested in tui.notifications, as in the list example above. That uses the terminal notification, so it depends on your terminal.
  • Use a Codex hook. A PermissionRequest hook runs when Codex is about to ask you. A hook that shows a notification and prints nothing leaves the decision to the normal prompt.

How often Codex asks depends on your sandbox and approval settings, which are covered in Codex CLI approvals and sandbox modes.

Which should I use?

Situation Use
Your terminal supports OSC 9 notifications tui.notifications
Any other terminal, or you want a sound notify with a script
You need to know about approvals tui.notifications with approval-requested, or a hook

The Claude Code version of this setup is in getting notified when Claude Code is waiting.

What do notifications leave out?

A notification says that something happened. To act on it you still go and find the right terminal, and an approval is still typed there.

NotchDaddy connects to Codex CLI through its hooks and shows each session in the MacBook notch. When Codex asks for approval, the request appears there with the command and Allow and Deny buttons, and an unanswered one goes back to Codex’s own prompt. It also takes status cards from your own scripts over a local HTTP endpoint, so a build or deploy can report into the same place.

You do not need it if a ping is all you want. The notify script above does that for free in a couple of minutes. What the notch adds is described on the agents page.

Start a 3-day trial for $0, then $19 once.