Documentation
¶
Overview ¶
Package notify resolves the fixed programs a session's watcher runs when a teammate's message arrives and the member asked to be told (cards 35 and 36): a quiet system sound through the platform's own player (`message_sound`), and a desktop notification through the platform's own notifier (`message_notification`). Each is an argument list nothing from the message ever reaches: the sound's is fixed at resolve time; the banner's carries Brigade's own title and text, and the session's own name and a count, as arguments — never spliced into script code. The hook uses the resolvers to say at session start when the machine cannot; the watcher uses them to run. On Windows neither is a program (card 153): the sound is winmm's PlaySound and the notification a notification-area balloon through Shell_NotifyIcon, both called in the watcher's own process, so the resolvers answer with a descriptor (WindowsSound, WindowsBanner) that InProcess recognises and RunInProcess runs, and nothing is spawned.
Index ¶
- Constants
- func Banner(goos string, lookPath func(name string) (string, bool)) ([]string, string)
- func BannerArgv(base []string, sessionID, name string, count int) []string
- func Close()
- func Exists(path string) bool
- func InProcess(argv []string) bool
- func LookPath(pathVar, name string) (string, bool)
- func RunInProcess(_ context.Context, argv []string) error
- func Sound(goos string, lookPath func(name string) (string, bool), ...) ([]string, string)
- func Text(name string, count int) string
Constants ¶
const ( DefaultInterval = 30 * time.Second IntervalFloor = 5 * time.Second IntervalCeiling = 3600 * time.Second )
The interval between two sounds, or two banners, for one session — a burst of messages is one of each, not a nuisance. DefaultInterval applies unless the member's `message_interval` option says otherwise (card 38), within IntervalFloor (a burst must not become a flood) and IntervalCeiling (an hour: past that the option is a way to switch off).
const ( WindowsSound = "winmm.dll:PlaySound" WindowsBanner = "shell32.dll:Shell_NotifyIcon" )
The Windows descriptors (card 153): what Sound and Banner answer on Windows in place of a program's path, naming the DLL call RunInProcess makes. Neither is ever spawned; the announcer asks InProcess first.
const ( WhyNoPlayerDarwin = "afplay is not on PATH" WhyNoPlayerLinux = "paplay is not on PATH" WhyNoFile = "the system sound file is missing" WhyNoNotifierDarwin = "neither terminal-notifier nor osascript is on PATH" WhyNoNotifierLinux = "notify-send is not on PATH" WhyUnknownOS = "no player or notifier is known for this system" )
The reasons Sound and Banner give for a machine that cannot: fixed text, safe on a session-start line, naming what to install.
const Timeout = 10 * time.Second
Timeout bounds one run; a player or notifier that has not returned by then is ended (SIGTERM, then SIGKILL after the spawn seam's wait delay).
const Title = "Brigade"
Title is the banner's title, Brigade's own word.
Variables ¶
This section is empty.
Functions ¶
func Banner ¶
Banner is the notifier this machine has, as a one-element argv that BannerArgv completes for each showing, or nil and the reason it has none. Nothing here runs a program.
func BannerArgv ¶
BannerArgv completes a Banner argv for one showing: the notifier's own flags, the title, the text for the session's name and the count, and — for terminal-notifier — a group per session so a burst replaces the previous banner. Every value is an argument. osascript reads its script from -e statements and the title and text from its run handler's argv, so a name can hold quotes, parentheses or an apostrophe and stay data; notify-send takes the summary and the body as arguments, the body's markup characters escaped because a daemon may parse it, and its backslashes doubled because notify-send decodes backslash escapes (g_strcompress) before the daemon sees the text. The Windows descriptor gets the title and the text as the two arguments RunInProcess reads, nothing else. An argv whose program is none of these is given notify-send's shape: a test seam, or a notifier the member put on PATH under another name, is treated as the plainest of them.
func InProcess ¶ added in v0.42.0
InProcess reports whether argv is a Windows descriptor: nothing to spawn, RunInProcess runs it.
func LookPath ¶
LookPath searches pathVar (a PATH value) for an executable regular file named name and returns the first hit. A relative entry — "" and "." included — is skipped, as foldersync skips it: a program is never started from a path relative to whatever the cwd happens to be, and the hook probes from the project directory. The hook's own search for the shadowing check of 6.2 keeps a shell's reading, on purpose: there the question is what a shell would run.
func RunInProcess ¶ added in v0.42.0
RunInProcess is Windows' alone (notify_windows.go): on every other platform a descriptor is an error, since Sound and Banner never answer one here.
func Sound ¶
func Sound(goos string, lookPath func(name string) (string, bool), exists func(path string) bool) ([]string, string)
Sound is the fixed argv of the player this machine has, or nil and the reason it has none. goos is runtime.GOOS; lookPath searches PATH for an executable name (the caller's own search, so the hook's and the watcher's seams both serve); exists says whether a file is present. Nothing here runs a program.
Types ¶
This section is empty.