Documentation
¶
Index ¶
Constants ¶
const ( // MethodAuto uses the terminal when it is known to understand the // sequence, and the system otherwise. The default. MethodAuto = "auto" // MethodTerminal always asks the terminal, for one the allowlist does // not know. A terminal that does not understand it prints it. MethodTerminal = "terminal" // MethodSystem always uses the platform's own notifier — notify-send // on Linux, osascript on macOS, which posts as Script Editor. MethodSystem = "system" )
Delivery methods for NewNotifier.
Variables ¶
This section is empty.
Functions ¶
func ResolveMethod ¶
ResolveMethod normalises a configured value, falling back to the default for an empty or unrecognised one: a typo in a cosmetic setting should cost the user the setting, not the client.
Types ¶
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier sends desktop notifications.
func NewNotifier ¶
NewNotifier creates a new notification dispatcher.
func (*Notifier) Notify ¶
Notify posts a desktop notification and returns the escape sequence the caller must write to the terminal, or "" when there is nothing to write.
It returns a sequence rather than writing one because this process does not own the terminal: Bubble Tea does, and a goroutine writing to the same file descriptor can land in the middle of a frame. The caller hands the result to tea.Raw, which puts it in the renderer's own output buffer, under the renderer's own lock, between frames.
The system path has no such problem and is taken here, in the background — notify-send and osascript are processes, and waiting on one would stall the event loop for as long as the desktop takes to answer.
type SoundPlayer ¶
type SoundPlayer struct {
// contains filtered or unexported fields
}
SoundPlayer plays notification sounds.
func NewSoundPlayer ¶
func NewSoundPlayer(enabled bool) *SoundPlayer
NewSoundPlayer creates a new sound player.
type TerminalSupport ¶
type TerminalSupport int
TerminalSupport is what a terminal will accept.
const ( // TerminalNone means send nothing: a terminal that does not understand // the sequence PRINTS it, which would drop `]777;notify;Ana;hi` into // the middle of somebody's chat. The failure is asymmetric, so this is // an allowlist and the default answer is no. TerminalNone TerminalSupport = iota // TerminalTitleAndBody takes OSC 777. TerminalTitleAndBody // TerminalBodyOnly takes OSC 9. TerminalBodyOnly )