blob: bddaf9ea3aa77645314f1c6a758908d545f7c575 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// +build darwin
package notification
import (
"fmt"
"os/exec"
"strconv"
)
// Notify sends a desktop notification to the user using osascript. It
// handles information in the form of Notif struct. It returns an
// error (if exists).
func (n Notif) Notify() error {
// This script cuts out parts of notification, this bug was
// confirmed on macOS Catalina 10.15.3, fix not yet known.
err := exec.Command("osascript", "-e",
`display notification `+strconv.Quote(n.Message)+` with title `+strconv.Quote(n.Title)).Run()
if err != nil {
err = fmt.Errorf("%s\n%s",
"notify_darwin.go: failed to sent notification with osascript",
err.Error())
}
return err
}
|