Documentation
¶
Overview ¶
Package termnotify asks the terminal to show a desktop notification. Terminals never agreed on one sequence, so it picks one by what the terminal is: OSC 99 for kitty, OSC 9 for iTerm2, WezTerm and Ghostty, OSC 777 notify for foot, and a bell everywhere else, which most terminals turn into a badge, a bounce of the dock icon or a flash. Inside tmux the sequence is wrapped so tmux passes it on to the terminal it runs in, when tmux's allow-passthrough option lets it.
Index ¶
Constants ¶
const ( MaxTitle = 64 MaxBody = 256 )
The longest title and body sent, in runes. Notifications show little more, and the protocols' own limits are larger.
Variables ¶
This section is empty.
Functions ¶
func Passthrough ¶
Passthrough wraps seq for tmux to pass on to the terminal outside it: DCS tmux ; seq ST, with each ESC in seq doubled.
Types ¶
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
Notifier sends notifications to a terminal, and keeps the time of the user's last key, so a caller can notify only someone who has looked away. Its methods are safe to call from any goroutine, and on a nil Notifier do nothing.
func ForTerminal ¶
ForTerminal is New for w, mdsh's own terminal, detected from the process's environment, and from tmux when it runs under tmux.
func New ¶
New sends to w, the terminal, by p; with tmux set, wrapped for tmux to pass on. A nil w or Off gives a nil Notifier.
type Protocol ¶
type Protocol int
Protocol is a way to ask for a notification.
const ( // Bell rings the terminal's bell, BEL. Bell Protocol = iota // OSC9 is iTerm2's OSC 9 ; text, which WezTerm and Ghostty take // too. OSC9 // OSC99 is kitty's OSC 99, with a title and a body. OSC99 // OSC777 is urxvt's OSC 777 ; notify ; title ; body, which foot // takes. OSC777 // Off sends nothing. Off )
func Detect ¶
Detect picks the protocol for the terminal env describes. MDSH_NOTIFY overrides it: off, bell, osc9, osc99 or osc777. Inside tmux, where TERM and TERM_PROGRAM name tmux, use DetectTmux.
func DetectTmux ¶
DetectTmux picks the protocol inside tmux, from what tmux says of the terminal outside it. A notification needs passthrough; without it, a bell, which tmux marks on the window and passes on as its bell-action says.
type Tmux ¶
type Tmux struct {
// TermName is the client's TERM, such as xterm-kitty, and TermType
// the terminal's own name and version, from XTVERSION, such as
// "iTerm2 3.5.4" (tmux 3.3 and later).
TermName, TermType string
// Passthrough is the pane's allow-passthrough option: off, on or
// all.
Passthrough string
}
Tmux is what tmux says of the terminal its client runs in, and of the pane mdsh runs in.