aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/main.go b/main.go
index a03a67d..592f770 100644
--- a/main.go
+++ b/main.go
@@ -5,7 +5,9 @@ import (
"flag"
"fmt"
"os"
+ "os/exec"
"os/signal"
+ "runtime"
"strings"
"time"
)
@@ -128,3 +130,30 @@ func main() {
for s := o.doWork; s != nil; s = s(ctx) {
}
}
+
+const title = "Pomodoro timer"
+
+func notifyX11(s string) error {
+ msg := fmt.Sprintf("%s\n\n%s", title, s)
+ return exec.Command("xmessage", "-center", "-timeout", "5", msg).Run()
+}
+
+func notifyOSX(s string) error {
+ msg := fmt.Sprintf("display notification %q with title %q", s, title)
+ return exec.Command("osascript", "-e", msg).Run()
+}
+
+func notifyLnx(s string) error {
+ return exec.Command("notify-send", title, s).Run()
+}
+
+func notify(s string) error {
+ switch runtime.GOOS {
+ case "darwin":
+ return notifyOSX(s)
+ case "linux":
+ return notifyLnx(s)
+ default: // *BSD
+ return notifyX11(s)
+ }
+}