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

21 lines · 554 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// Alert displays a desktop notification and plays a default system sound.
12func Alert(title, message, appIcon string) error {
13	osa, err := exec.LookPath("osascript")
14	if err != nil {
15		return err
16	}
17
18	script := fmt.Sprintf("display notification %q with title %q sound name \"default\"", message, title)
19	cmd := exec.Command(osa, "-e", script)
20	return cmd.Run()
21}