Skip to content

Instantly share code, notes, and snippets.

@LeZuse
Last active March 12, 2026 21:50
Show Gist options
  • Select an option

  • Save LeZuse/e24c5796a952ab1aea308ca415eb6166 to your computer and use it in GitHub Desktop.

Select an option

Save LeZuse/e24c5796a952ab1aea308ca415eb6166 to your computer and use it in GitHub Desktop.
Claude Code idle mobile notification for free
# Claude Code Notification hook - sends push via Bark API
# Reads JSON from stdin with: message, title, notification_type
# Usage:
# 1. install Bark app and register your device (https://apps.apple.com/us/app/bark-custom-notifications/id1403753865)
# 2. put this file in ~/.claude/hooks/
# 3. replace BARK_API_SECRET with your secret from the app
# 4. update your ~/.claude/settings.json (example below)
BARK_API_SECRET="xxxxxxxx"
INPUT=$(cat)
# Get tmux session name if running inside tmux
TMUX_SESSION=""
if [ -n "$TMUX" ]; then
TMUX_SESSION=$(tmux display-message -p '#S' 2>/dev/null)
fi
RAW_TITLE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('title','Claude Code'))" 2>/dev/null || echo "Claude Code")
if [ -n "$TMUX_SESSION" ]; then
TITLE="${RAW_TITLE} [${TMUX_SESSION}]"
else
TITLE="$RAW_TITLE"
fi
MESSAGE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('message','Waiting for your input'))" 2>/dev/null || echo "Waiting for your input")
# URL-encode title and message
ENCODED_TITLE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$TITLE'))" 2>/dev/null)
ENCODED_MESSAGE=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$MESSAGE" 2>/dev/null)
curl -s -X POST "https://api.day.app/${BARK_API_SECRET}/${ENCODED_TITLE}/${ENCODED_MESSAGE}?url=termius:///terminals" > /dev/null 2>&1
# Claude Code Notification hook - sends push via Bark API
# Reads JSON from stdin with: message, title, notification_type
# Usage:
# 1. install Bark app and register your device (https://apps.apple.com/us/app/bark-custom-notifications/id1403753865)
# 2. put this file in ~/.claude/hooks/
# 3. replace BARK_API_SECRET with your secret from the app
# 4. update your ~/.claude/settings.json (example below)
BARK_API_SECRET="xxxxxxxx"
INPUT=$(cat)
TITLE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('title','Claude Code'))" 2>/dev/null || echo "Claude Code")
MESSAGE=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('message','Waiting for your input'))" 2>/dev/null || echo "Waiting for your input")
# URL-encode title and message
ENCODED_TITLE=$(python3 -c "import urllib.parse; print(urllib.parse.quote('$TITLE'))" 2>/dev/null)
ENCODED_MESSAGE=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1]))" "$MESSAGE" 2>/dev/null)
curl -s -X POST "https://api.day.app/${BARK_API_SECRET}/${ENCODED_TITLE}/${ENCODED_MESSAGE}" > /dev/null 2>&1
{
"hooks": {
"Notification": [
{
"hooks": [
{
"type": "command",
"command": "/Users/zuse/.claude/hooks/notify-mobile.sh"
}
]
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment