forked from mehdieidi/lomodoro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (32 loc) · 758 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package main
import (
"flag"
"fmt"
"time"
"github.com/gen2brain/beeep"
)
func main() {
workDuration := flag.Int("w", 25, "how much minutes do you work?")
breakDuration := flag.Int("b", 2, "how much minutes do you rest?")
flag.Parse()
fmt.Printf("work: %d mins, break: %d mins\n", *workDuration, *breakDuration)
ticker := time.NewTicker(time.Duration(*workDuration) * time.Minute)
count := 1
for {
select {
case <-ticker.C:
fmt.Println("Break number ", count)
count++
topic := "break"
text := "enough man! go get some rest."
notify(topic, text)
}
time.Sleep(time.Duration(*breakDuration) * time.Minute)
}
}
func notify(topic, text string) {
err := beeep.Notify(topic, text, "")
if err != nil {
panic(err)
}
}