aboutsummaryrefslogtreecommitdiffstats
path: root/notifier_windows.go
diff options
context:
space:
mode:
authorGabriel Handford2016-05-06 15:20:54 -0700
committerGabriel Handford2016-05-06 15:57:46 -0700
commit12878f6400420fa6c988187c8942799b73c31e6c (patch)
tree4c134f3bbf0ea6ebd4f3b8cdad6bf27ec903da4d /notifier_windows.go
downloadgo-notifier-12878f6400420fa6c988187c8942799b73c31e6c.tar.bz2
Importing
Diffstat (limited to 'notifier_windows.go')
-rw-r--r--notifier_windows.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/notifier_windows.go b/notifier_windows.go
new file mode 100644
index 0000000..3f6ce09
--- /dev/null
+++ b/notifier_windows.go
@@ -0,0 +1,44 @@
+// Copyright 2016 Keybase, Inc. All rights reserved. Use of
+// this source code is governed by the included BSD license.
+
+package notifier
+
+import (
+ "fmt"
+ "os/exec"
+)
+
+type windowsNotifier struct{}
+
+// NewNotifier constructs notifier for Windows
+func NewNotifier() (Notifier, error) {
+ return &windowsNotifier{}, nil
+}
+
+// DeliverNotification sends a notification
+func (n windowsNotifier) DeliverNotification(notification Notification) error {
+ args := []string{}
+
+ if notification.Title != "" {
+ args = append(args, "-t", notification.Title)
+ }
+ if notification.Message != "" {
+ args = append(args, "-m", notification.Message)
+ }
+ if notification.ImagePath != "" {
+ args = append(args, "-p", notification.ImagePath)
+ }
+
+ // For testing
+ // toastPath := filepath.Join(os.Getenv("GOPATH"), "src/github.com/keybase/go-osnotify/toaster/toast.exe")
+
+ cmd := exec.Command(notification.toastPath, args...)
+ if cmd == nil {
+ return fmt.Errorf("No command")
+ }
+ _, err := cmd.Output()
+ if err != nil {
+ return fmt.Errorf("Error running command: %s", err)
+ }
+ return nil
+}