Cross platform system notifications in go (golang).
For OS X, we use NSUserNotificationCenter APIs from cgo. This only supports OS X 10.9 and above.
For Windows, we use toaster. This only supports Windows 8 and above.
For Linux, we use notify-send.
go install github.com/keybase/go-notifier/notifier
If you need alert style (actionable) notifications (on OS X), you need to include an Info.plist
in the binary and sign it. You can look at build_darwin.sh
on how to do this.
notifier --title="Hi" --message="Test message" --bundle-id=keybase.Electron --timeout=20 --action=Close
If action is chosen, you get output (stdout):
{"type":"action","action":"Close"}
If the notification contents are clicked,
{"type":"clicked"}
notifier --title="Hi" --message="Test message" --bundle-id=keybase.Electron --timeout=20 --action=Close --action="Install" --action="Ignore"
Follows similar requirements of node-notifier, but only supports recent platform versions.
Instead of deckarep/gosx-notifier, which uses an embedded version of terminal-notifier, this implementation uses cgo to talk directly to NSUserNotificationCenter APIs. It is also possible to use AppleScript APIs to generate notifications (see this post), but a cgo implementation was preferable.
The 0xAX/notificator only supports growlnotify on Windows and OS X.
The vjeantet/alerter app allows you to use alert style notifications on OS X.