極光日記

Notify on Completion with Antigravity CLI

Created:

Notify on Process Completion in Antigravity CLI

Here is how to set up desktop notifications whenever an agent finishes its task in Antigravity CLI (agy cli).
The notification looks like this:

Antigravity CLI notification

  • Antigravity CLI version: 1.1.12
  • Tested environment: Ubuntu Desktop (Adjustments may be needed for Windows or macOS)
  • Note: This article covers configuration specifically for the CLI. I do not use the Antigravity desktop app or Antigravity IDE.

Configuring Hooks

Antigravity features a Hooks functionality that triggers commands or scripts at specific lifecycle events.

On Linux, Hooks are configured in ~/.gemini/config/hooks.json (create the file if it does not exist).

Here is my configuration:

{
  "reminder": {
    "Stop": [
      {
        "type": "command",
        "command": "bash /home/YOUR_USER_NAME/agy.sh"
      }
    ]
  }
}

Official documentation for hooks can be found here:

  • reminder: Name of the hook (an arbitrary identifier string).
  • Stop: Specifies the timing when agent execution stops or completes.
  • command: Specifies the path to the shell script to execute (replace YOUR_USER_NAME with your actual username).

The agy.sh script is as follows:

#!/usr/bin/env bash

INPUT_JSON=$(cat -)

# Triggered when waiting for user input (fullyIdle: true)
if echo "${INPUT_JSON}" | jq -e '.fullyIdle == true' >/dev/null 2>&1; then
    # Desktop notification
    notify-send "Antigravity CLI" "✅ DONE" --urgency=normal -t 5000 2>/dev/null &
    
    # Sound notification example:
    paplay /usr/share/sounds/freedesktop/stereo/complete.oga 2>/dev/null || printf '\a'
fi

echo '{"decision": "other"}'

When invoking configured commands, hooks pass a JSON payload to standard input (stdin). See the documentation for the exact payload schema.

When the CLI becomes completely idle waiting for input, the payload contains fullyIdle: true. We check for this condition to run notify-send and paplay.

Both notify-send and paplay are pre-installed on Ubuntu Desktop; install them if they are missing on your system.

The script also uses jq to parse JSON, which needs to be installed as well.

The arguments for notify-send are:

  • First argument: Summary (serves as the notification title)
  • Second argument: Body text
  • --urgency: Urgency level (low, normal, critical). In my environment, low did not display desktop popups.
  • -t: Expiration time in milliseconds before the notification auto-dismisses.

paplay plays the audio file provided as its argument.

Finally, the script outputs {"decision": "other"} to standard output (stdout).

According to the documentation, returning "continue" prevents the agent from stopping. If set to "continue", the process gets caught in an endless run-stop loop and notifications pop up continuously.

Returning any string other than "continue" (such as "other" or "stop") allows the agent to halt and wait for input properly.

Troubleshooting

Logs for Antigravity CLI are output to ~/.gemini/antigravity-cli/log/.

If something isn’t working as expected, check the logs in this directory.