bell.go

 1package notification
 2
 3import (
 4	"log/slog"
 5
 6	tea "charm.land/bubbletea/v2"
 7)
 8
 9// BellBackend sends notifications by triggering the terminal bell. This is the
10// most basic notification mechanism and works in virtually all terminals, but
11// provides no visual message — just an audible or visual alert depending on
12// terminal configuration.
13type BellBackend struct{}
14
15// NewBellBackend creates a new bell notification backend.
16func NewBellBackend() *BellBackend {
17	return &BellBackend{}
18}
19
20// Send returns a [tea.Cmd] that triggers the terminal bell character (\x07).
21// The terminal will emit an audible beep or visual flash based on user
22// configuration. No message text is displayed.
23func (b *BellBackend) Send(n Notification) tea.Cmd {
24	slog.Debug("Sending bell notification", "title", n.Title, "message", n.Message)
25
26	return tea.Raw("\x07")
27}