Claude notifications: clicking one brings back the app Claude runs in
shellcheck / shellcheck (push) Successful in 18s
shellcheck / shellcheck (push) Successful in 18s
The hooks ran notify-send from inside Claude, so GNOME couldn't tell which app the notification came from and clicking it did nothing. system/claude-notify finds the terminal or editor among Claude's parent processes (or tmux's client, or the Flatpak) and names it in the desktop-entry hint. The title shows the project folder and the body Claude's own message. claude.sh swaps the old notify-send hooks for it, only where they're still the ones CoreDesktop wrote, and 70-claude.sh now runs claude.sh on every update so existing machines get it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,14 +21,35 @@ else
|
||||
echo "\~/.local/bin added to PATH in .bashrc"
|
||||
fi
|
||||
|
||||
# Desktop notifications via notify-send (libnotify)
|
||||
# Desktop notifications, through system/claude-notify so that clicking one
|
||||
# brings back the app Claude is running in
|
||||
SETTINGS_FILE="$HOME/.claude/settings.json"
|
||||
# The hook runs in a shell, which expands ~
|
||||
# shellcheck disable=SC2088
|
||||
NOTIFY="~/.local/share/coredesktop/system/claude-notify"
|
||||
if [ -f "$SETTINGS_FILE" ]; then
|
||||
echo "Claude Code settings already exist at $SETTINGS_FILE"
|
||||
# Settings written before claude-notify ran notify-send itself, so clicking
|
||||
# did nothing. Change those two hooks, and only those: any others are yours.
|
||||
tmp="$(mktemp "$SETTINGS_FILE.XXXXXX")"
|
||||
if jq --arg notify "$NOTIFY" \
|
||||
--arg old_input "notify-send 'Claude Code' 'Needs your input'" \
|
||||
--arg old_done "notify-send 'Claude Code' 'Task completed'" '
|
||||
def swap(old; new):
|
||||
if type == "object" and .command == old then .command = new else . end;
|
||||
(.hooks.Notification[]?.hooks[]?) |= swap($old_input; "\($notify) '"'Needs your input'"'")
|
||||
| (.hooks.Stop[]?.hooks[]?) |= swap($old_done; "\($notify) '"'Task completed'"'")
|
||||
' "$SETTINGS_FILE" > "$tmp" \
|
||||
&& ! jq -e --slurpfile new "$tmp" '. == $new[0]' "$SETTINGS_FILE" > /dev/null; then
|
||||
echo "Making Claude Code's notifications clickable..."
|
||||
mv -f "$tmp" "$SETTINGS_FILE"
|
||||
else
|
||||
rm -f "$tmp"
|
||||
fi
|
||||
else
|
||||
echo "Writing Claude Code settings to $SETTINGS_FILE..."
|
||||
mkdir -p "$(dirname "$SETTINGS_FILE")"
|
||||
cat > "$SETTINGS_FILE" <<'EOF'
|
||||
cat > "$SETTINGS_FILE" <<EOF
|
||||
{
|
||||
"hooks": {
|
||||
"Notification": [
|
||||
@@ -37,7 +58,7 @@ else
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "notify-send 'Claude Code' 'Needs your input'"
|
||||
"command": "$NOTIFY 'Needs your input'"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -48,7 +69,7 @@ else
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "notify-send 'Claude Code' 'Task completed'"
|
||||
"command": "$NOTIFY 'Task completed'"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user