From eee7c8190d7232391287f8ba46191659066d2b5f Mon Sep 17 00:00:00 2001 From: alexion Date: Fri, 10 Jul 2026 22:48:01 -0400 Subject: [PATCH] claude: Add attention-bell hook so tmux flags Claude sessions needing input Wire Stop and Notification hooks in ~/.claude/settings.json to a new ~/.claude/hooks/attention-bell.sh, which rings the terminal bell in the session pane so tmux monitor-bell flags the background window. The hook runs detached (no controlling tty), so it walks its process ancestry to the claude process and writes the BEL to that pane tty. Also replaces the dead settings.json symlink (pointed at a now-missing ~/wrk/claude path) with a real tracked file. --- .claude/hooks/attention-bell.sh | 21 +++++++++++++++++++++ .claude/settings.json | 19 ++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100755 .claude/hooks/attention-bell.sh mode change 120000 => 100644 .claude/settings.json diff --git a/.claude/hooks/attention-bell.sh b/.claude/hooks/attention-bell.sh new file mode 100755 index 0000000..0b83487 --- /dev/null +++ b/.claude/hooks/attention-bell.sh @@ -0,0 +1,21 @@ +#!/bin/sh +# attention-bell.sh — ring the terminal bell in this Claude session's tmux pane +# so tmux's monitor-bell flags the (background) window red in the status bar. +# +# Claude Code runs hooks as detached subprocesses: they have no controlling +# terminal, so /dev/tty is unavailable here. But the parent-process chain up to +# the `claude` process stays intact, and `claude` itself holds the pane's pty. +# So we walk ancestry to find it and write the bell straight to that tty. +# (Writing a bare BEL to an explicit /dev/pts/N works even from a detached +# process — verified against tmux's window_bell_flag.) + +pid=$PPID +while [ "$pid" -gt 1 ] 2>/dev/null; do + if [ "$(ps -o comm= -p "$pid" 2>/dev/null)" = claude ]; then + tty=$(ps -o tty= -p "$pid" 2>/dev/null | tr -d ' ') + [ -n "$tty" ] && [ "$tty" != '?' ] && printf '\a' > "/dev/$tty" + exit 0 + fi + pid=$(ps -o ppid= -p "$pid" 2>/dev/null | tr -d ' ') + [ -z "$pid" ] && break +done diff --git a/.claude/settings.json b/.claude/settings.json deleted file mode 120000 index b029f31..0000000 --- a/.claude/settings.json +++ /dev/null @@ -1 +0,0 @@ -/home/alexion/wrk/claude/settings.json \ No newline at end of file diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..a35212a --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,18 @@ +{ + "hooks": { + "Stop": [ + { + "hooks": [ + { "type": "command", "command": "~/.claude/hooks/attention-bell.sh" } + ] + } + ], + "Notification": [ + { + "hooks": [ + { "type": "command", "command": "~/.claude/hooks/attention-bell.sh" } + ] + } + ] + } +}