Skip to content

go-notifier: Cross platform system notifications in go (golang)

License

Notifications You must be signed in to change notification settings

gemsi/go-notifier

 
 

Repository files navigation

go-notifier

Cross platform system notifications in go (golang).

Platforms

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.

Install

go install github.com/keybase/go-notifier/notifier

Alerts

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.

Examples (OS X)

Notification with single action

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"}

Notification with multiple actions

notifier --title="Hi" --message="Test message" --bundle-id=keybase.Electron --timeout=20 --action=Close --action="Install" --action="Ignore"

Resources

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.

About

go-notifier: Cross platform system notifications in go (golang)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 68.8%
  • Objective-C 29.0%
  • Shell 2.2%