aboutsummaryrefslogtreecommitdiff
path: root/notification
diff options
context:
space:
mode:
Diffstat (limited to 'notification')
-rw-r--r--notification/notify_darwin.go5
-rw-r--r--notification/notify_linux.go11
-rw-r--r--notification/notify_unsupported.go23
-rw-r--r--notification/notify_windows.go7
4 files changed, 41 insertions, 5 deletions
diff --git a/notification/notify_darwin.go b/notification/notify_darwin.go
index 1d9cbbc..1e09ef8 100644
--- a/notification/notify_darwin.go
+++ b/notification/notify_darwin.go
@@ -31,7 +31,7 @@ func init() {
TerminalNotifierAvailable = true
}
-func Send(title, text string, critical bool) error {
+func Send(title, text string, critical, sound bool) error {
if TerminalNotifierAvailable {
args := []string{"-title", "gomuks", "-subtitle", title, "-message", text}
if critical {
@@ -39,6 +39,9 @@ func Send(title, text string, critical bool) error {
} else {
args = append(args, "-timeout", "4")
}
+ if sound {
+ args = append(args, "-sound", "default")
+ }
// if len(iconPath) > 0 {
// args = append(args, "-appIcon", iconPath)
// }
diff --git a/notification/notify_linux.go b/notification/notify_linux.go
index 25ab405..f8ecdaf 100644
--- a/notification/notify_linux.go
+++ b/notification/notify_linux.go
@@ -18,14 +18,21 @@ package notification
import "os/exec"
-func Send(title, text string, critical bool) error {
+func Send(title, text string, critical, sound bool) error {
args := []string{"-a", "gomuks"}
if critical {
- args = append(args, "-p", "critical")
+ args = append(args, "-u", "critical")
}
// if iconPath {
// args = append(args, "-i", iconPath)
// }
args = append(args, title, text)
+ if sound {
+ soundName := "message-new-instant"
+ if critical {
+ soundName = "complete"
+ }
+ exec.Command("paplay", "/usr/share/sounds/freedesktop/stereo/"+soundName+".oga").Run()
+ }
return exec.Command("notify-send", args...).Run()
}
diff --git a/notification/notify_unsupported.go b/notification/notify_unsupported.go
new file mode 100644
index 0000000..0b350e8
--- /dev/null
+++ b/notification/notify_unsupported.go
@@ -0,0 +1,23 @@
+// +build !linux,!darwin,!windows
+
+// gomuks - A terminal Matrix client written in Go.
+// Copyright (C) 2018 Tulir Asokan
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+package notification
+
+func Send(title, text string, critical, sound bool) error {
+ return nil
+}
diff --git a/notification/notify_windows.go b/notification/notify_windows.go
index 71c547d..d927ee1 100644
--- a/notification/notify_windows.go
+++ b/notification/notify_windows.go
@@ -18,15 +18,18 @@ package notification
import "gopkg.in/toast.v1"
-func Send(title, text string, critical bool) error {
+func Send(title, text string, critical, sound bool) error {
notification := toast.Notification{
AppID: "gomuks",
Title: title,
Message: message,
- Audio: toast.IM,
+ Audio: toast.Silent,
Duration: toast.Short,
// Icon: ...,
}
+ if sound {
+ notification.Audio = toast.IM
+ }
if critical {
notification.Duration = toast.Long
}