diff --git a/README.md b/README.md index 624b67f..164e536 100644 --- a/README.md +++ b/README.md @@ -418,10 +418,14 @@ prep command that exits abnormally to a desktop notifier. Since modd commands are shell scripts, you can redirect or manipulate output to entirely customise what gets sent to notifiers as needed. -At the moment, we support [Growl](http://growl.info/) on OSX, and +At the moment, we support [terminal-notifier](https://github.com/julienXX/terminal-notifier) and [Growl](http://growl.info/) on OSX, and [libnotify](https://launchpad.net/ubuntu/+source/libnotify) on Linux and other Unix systems. +## terminal-notifier + +terminal-notifier is a command-line tool to send macOS User Notifications, which are available on macOS 10.10 and higher. Follow the instructions in the [terminal-notifier GitHub repository](https://github.com/julienXX/terminal-notifier) to install. + ## Growl For Growl to work, you will need Growl itself to be running, and have the diff --git a/notify/notify.go b/notify/notify.go index 6faa1e3..c271808 100644 --- a/notify/notify.go +++ b/notify/notify.go @@ -40,6 +40,18 @@ func (GrowlNotifier) Push(title string, text string, iconPath string) { go cmd.Run() } +// TerminalNotifier is a notifier for terminal-notifier +type TerminalNotifier struct { +} + +// Push implements Notifier +func (TerminalNotifier) Push(title string, text string, iconPath string) { + cmd := exec.Command( + "terminal-notifier", "-title", prog, "-subtitle", title, "-message", text, + ) + go cmd.Run() +} + // LibnotifyNotifier is a notifier for lib-notify type LibnotifyNotifier struct { } @@ -54,7 +66,9 @@ func (LibnotifyNotifier) Push(title string, text string, iconPath string) { // PlatformNotifier finds a notifier for this platform func PlatformNotifier() Notifier { - if hasExecutable("growlnotify") { + if hasExecutable("terminal-notifier") { + return &TerminalNotifier{} + } else if hasExecutable("growlnotify") { return &GrowlNotifier{} } else if hasExecutable("notify-send") { return &LibnotifyNotifier{}