Commit 4bd2c70cd678

Vincent Demeester <vincent@sbr.pm>
2025-12-10 12:41:06
feat(claude-hooks): Add desktop notifications for hook execution
- Provide visual feedback when sessions start, end, and tools execute - Help users verify hooks are working correctly - Improve visibility into Claude Code session lifecycle Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent eaeca9f
Changed files (3)
tools
claude-hooks
cmd
capture-tool-output
initialize-session
save-session
tools/claude-hooks/cmd/capture-tool-output/main.go
@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"io"
 	"os"
+	"os/exec"
 	"path/filepath"
 	"time"
 
@@ -111,5 +112,13 @@ func main() {
 		os.Exit(0) // Silent failure
 	}
 
+	// Send desktop notification
+	notifyMsg := fmt.Sprintf("Tool executed: %s", data.ToolName)
+	cmd := exec.Command("notify-send", "-u", "low", "Claude Hook", notifyMsg)
+	if err := cmd.Run(); err != nil {
+		// Silent failure - don't break workflow
+		fmt.Fprintf(os.Stderr, "[capture-tool-output] Warning: Could not send notification: %v\n", err)
+	}
+
 	os.Exit(0)
 }
tools/claude-hooks/cmd/initialize-session/main.go
@@ -3,6 +3,7 @@ package main
 import (
 	"fmt"
 	"os"
+	"os/exec"
 	"path/filepath"
 	"strconv"
 	"strings"
@@ -103,6 +104,13 @@ func main() {
 	setTerminalTitle(tabTitle)
 	fmt.Fprintf(os.Stderr, "๐Ÿ“ Session initialized: \"%s\"\n", tabTitle)
 
+	// Send desktop notification
+	cmd := exec.Command("notify-send", "-u", "low", "Claude Code", "Session started")
+	if err := cmd.Run(); err != nil {
+		// Silent failure - don't break workflow
+		fmt.Fprintf(os.Stderr, "[initialize-session] Warning: Could not send notification: %v\n", err)
+	}
+
 	// Log session start to history (silent failure)
 	if err := logSessionStart(); err != nil {
 		// Don't break session start for logging issues
tools/claude-hooks/cmd/save-session/main.go
@@ -3,6 +3,7 @@ package main
 import (
 	"fmt"
 	"os"
+	"os/exec"
 )
 
 // isSubagentSession checks if this is a subagent session
@@ -24,6 +25,13 @@ func main() {
 		os.Exit(0)
 	}
 
+	// Send desktop notification
+	cmd := exec.Command("notify-send", "-u", "low", "Claude Code", "Session ending")
+	if err := cmd.Run(); err != nil {
+		// Silent failure - don't break workflow
+		fmt.Fprintf(os.Stderr, "[save-session] Warning: Could not send notification: %v\n", err)
+	}
+
 	// Output prompt for Claude to save the session
 	// This will be shown in the conversation
 	fmt.Println("")