diff options
author | Andinus <andinus@nand.sh> | 2020-03-25 00:13:51 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-25 00:13:51 +0530 |
commit | 3ee3715ae7777dd6c1804974e2e293406fd1fe54 (patch) | |
tree | f035e76ff9ce48d03299381d03906eaff76140dc /notification/notify_darwin.go | |
parent | 28e35c0b0b996e17bd94a5b9e78fda90086ba85e (diff) | |
download | cetus-3ee3715ae7777dd6c1804974e2e293406fd1fe54.tar.gz |
Add apod support & fix errors
Diffstat (limited to 'notification/notify_darwin.go')
-rw-r--r-- | notification/notify_darwin.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/notification/notify_darwin.go b/notification/notify_darwin.go new file mode 100644 index 0000000..bddaf9e --- /dev/null +++ b/notification/notify_darwin.go @@ -0,0 +1,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 +} |