vendor/github.com/gen2brain/beeep/notify_darwin.go

23 lines · 561 bytes

 1//go:build darwin && !linux && !freebsd && !netbsd && !openbsd && !windows && !js
 2// +build darwin,!linux,!freebsd,!netbsd,!openbsd,!windows,!js
 3
 4package beeep
 5
 6import (
 7	"fmt"
 8	"os/exec"
 9)
10
11// Notify sends desktop notification.
12//
13// On macOS this executes AppleScript with `osascript` binary.
14func Notify(title, message, appIcon string) error {
15	osa, err := exec.LookPath("osascript")
16	if err != nil {
17		return err
18	}
19
20	script := fmt.Sprintf("display notification %q with title %q", message, title)
21	cmd := exec.Command(osa, "-e", script)
22	return cmd.Run()
23}