-
Notifications
You must be signed in to change notification settings - Fork 0
/
timer.go
46 lines (35 loc) · 869 Bytes
/
timer.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
43
44
45
46
package main
import (
"context"
"time"
"github.com/gen2brain/beeep"
"github.com/wailsapp/wails/v2/pkg/runtime"
)
type Timer struct {
ctx context.Context
}
func NewTimer() *Timer {
return &Timer{}
}
func (a *Timer) timerStartup(ctx context.Context) {
a.ctx = ctx
err := beeep.Alert("Theia", "Timer has been started", "")
if err != nil {
println("Error:", err.Error())
}
}
func (a *Timer) Time() {
err := beeep.Alert("Timer", "It's time to look away from the screen mate! Look at an object far away for 20s", "")
if err != nil {
println("Error:", err.Error())
}
runtime.WindowShow(a.ctx)
time.AfterFunc(20 * time.Second, func () {
runtime.WindowHide(a.ctx)
err := beeep.Alert("Timer Over", "You can look back at the screen now", "")
if err != nil {
println("Error:", err.Error())
}
runtime.WindowReloadApp(a.ctx)
})
}