hayai/vendor/github.com/gen2brain/beeep/alert_darwin.go
2024-12-21 17:26:50 +01:00

22 lines
554 B
Go

//go:build darwin && !linux && !freebsd && !netbsd && !openbsd && !windows && !js
// +build darwin,!linux,!freebsd,!netbsd,!openbsd,!windows,!js
package beeep
import (
"fmt"
"os/exec"
)
// Alert displays a desktop notification and plays a default system sound.
func Alert(title, message, appIcon string) error {
osa, err := exec.LookPath("osascript")
if err != nil {
return err
}
script := fmt.Sprintf("display notification %q with title %q sound name \"default\"", message, title)
cmd := exec.Command(osa, "-e", script)
return cmd.Run()
}