2026-07-21
Sometimes, I get up from my computer while working with Claude - usually to think while it’s working on something, or to take a break. I found out that when I do this, I don’t know what Claude is up to. For all I know, Claude got stuck 20 seconds in on a 5-minute task.
For that, I wrote a little script that helps. Claude already has facilities to notify when done, but they run on every interruption always, which is annoying when I’m already in front of my computer. Instead, I created a service that creates an “idle” file when I’m away from my PC. Claude checks this file when it’s done, and if it’s present, sends a notification on a custom ntfy.sh topic.
See the changes below:
settings.json:
{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": "( if [ -f ~/.claude/os-idle ]; then curl -s -H 'Title: Claude Code' -H 'Priority: default' -d 'Session finished' https://ntfy.sh/<SUPER SECRET TOKEN> >/dev/null 2>&1; fi ) 2>/dev/null || true"
}
]
}
],
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "( if [ -f ~/.claude/os-idle ]; then msg=$(jq -r '.message // \"Claude is waiting for you\"' 2>/dev/null); curl -s -H 'Title: Claude Code' -H 'Priority: high' -d \"$msg\" https://ntfy.sh/<SUPER-SECRET-TOKEN> >/dev/null 2>&1; fi ) 2>/dev/null || true"
}
]
}
]
}
}
swayidle.service:
[Unit]
Description=Track OS-level idle state for Claude Code notification hooks
PartOf=graphical-session.target
After=graphical-session.target
[Service]
Type=simple
ExecStart=/usr/bin/swayidle -w timeout 15 'touch %h/.claude/os-idle' resume 'rm -f %h/.claude/os-idle'
Restart=on-failure
RestartSec=5
[Install]
WantedBy=graphical-session.target