aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-04-12 02:37:22 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-04-12 02:37:22 +0200
commitf00cb4ada824714c238e6f78fe5f932b1c010f00 (patch)
tree2efa0bedd4eae6549ae395dc714736da411877e7
parentf013d67855055d7f56fb39134d988316554ca771 (diff)
Add notifications
-rw-r--r--main.go1
-rw-r--r--notify_osx.go13
-rw-r--r--notify_x11.go9
3 files changed, 23 insertions, 0 deletions
diff --git a/main.go b/main.go
index 9de4825..a03a67d 100644
--- a/main.go
+++ b/main.go
@@ -23,6 +23,7 @@ type Opt struct {
type stateFn func(context.Context) stateFn
func (o *Opt) display(ctx context.Context, s string) {
+ go notify(s)
dl, ok := ctx.Deadline()
if !ok {
return
diff --git a/notify_osx.go b/notify_osx.go
new file mode 100644
index 0000000..2e427e9
--- /dev/null
+++ b/notify_osx.go
@@ -0,0 +1,13 @@
+// +build darwin
+
+package main
+
+import (
+ "fmt"
+ "os/exec"
+)
+
+func notify(s string) error {
+ cmd := fmt.Sprintf("display notification %q with title %q", s, "Pomodoro")
+ return exec.Command("osascript", "-e", cmd).Run()
+}
diff --git a/notify_x11.go b/notify_x11.go
new file mode 100644
index 0000000..f698be1
--- /dev/null
+++ b/notify_x11.go
@@ -0,0 +1,9 @@
+// +build !darwin
+
+package main
+
+import "os/exec"
+
+func notify(s string) error {
+ return exec.Command("xmessage", "-center", "-timeout", "5", s).Run()
+}