From f00cb4ada824714c238e6f78fe5f932b1c010f00 Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Wed, 12 Apr 2017 02:37:22 +0200 Subject: Add notifications --- main.go | 1 + notify_osx.go | 13 +++++++++++++ notify_x11.go | 9 +++++++++ 3 files changed, 23 insertions(+) create mode 100644 notify_osx.go create mode 100644 notify_x11.go 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() +} -- cgit v1.2.3