aboutsummaryrefslogtreecommitdiffstats
path: root/notifier_linux.go
diff options
context:
space:
mode:
Diffstat (limited to 'notifier_linux.go')
-rw-r--r--notifier_linux.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/notifier_linux.go b/notifier_linux.go
new file mode 100644
index 0000000..7996354
--- /dev/null
+++ b/notifier_linux.go
@@ -0,0 +1,35 @@
+// 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 linuxNotifier struct{}
+
+// NewNotifier constructs notifier for Windows
+func NewNotifier() (Notifier, error) {
+ return &linuxNotifier{}, nil
+}
+
+// DeliverNotification sends a notification
+func (n linuxNotifier) DeliverNotification(notification Notification) error {
+ args := []string{}
+ if notification.ImagePath != "" {
+ args = append(args, "-i", notification.ImagePath)
+ }
+ args = append(args, notification.Title)
+ args = append(args, notification.Message)
+ cmd := exec.Command("notify-send", 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
+}