Skip to content

Commit 1cf2d5e

Browse files
committed
feat(hooks): add notify-send after agent hook
1 parent 254fd56 commit 1cf2d5e

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

.gemini/hooks/notify.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import subprocess
2+
import os
3+
import sys
4+
from utils import send_hook_decision
5+
6+
def notify_user():
7+
"""
8+
Sends a desktop notification using notify-send.
9+
Fails gracefully if notify-send is not available.
10+
"""
11+
try:
12+
# Get the project name from the current directory
13+
project_name = os.path.basename(os.getcwd())
14+
15+
# Determine the message based on the hook context
16+
message = f"Gemini CLI has finished in '{project_name}'"
17+
18+
# Try to call notify-send
19+
subprocess.run(
20+
["notify-send", "Gemini CLI", message, "--icon=terminal"],
21+
check=False,
22+
stderr=subprocess.DEVNULL,
23+
stdout=subprocess.DEVNULL
24+
)
25+
except Exception:
26+
# Gracefully handle cases where notify-send is not installed or fails
27+
pass
28+
29+
if __name__ == "__main__":
30+
# Perform the notification
31+
notify_user()
32+
33+
# Always allow the agent to proceed
34+
send_hook_decision("allow")

.gemini/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@
7676
"name": "update-journal-and-changelog",
7777
"type": "command",
7878
"command": "python3 .gemini/hooks/journal.py"
79+
},
80+
{
81+
"name": "notify-user",
82+
"type": "command",
83+
"command": "python3 .gemini/hooks/notify.py"
7984
}
8085
]
8186
}

0 commit comments

Comments
 (0)