Sebastian Mark
bbc9977f1c
- remove `shared` package and shared.Message - rename `notifications` package to `frontend` - introduce a channel send the received ServerMessages to the frontend handler(s) - move keyhandler to goroutine - simplify password handling in Start function - update import names when importing from GoTomoto
36 lines
1.1 KiB
Go
36 lines
1.1 KiB
Go
package frontend
|
|
|
|
import (
|
|
"fmt"
|
|
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
|
"github.com/gen2brain/beeep"
|
|
)
|
|
|
|
func desktopNotifications(pomodoro GoTomato.ServerMessage) {
|
|
|
|
var duration int
|
|
var notification string
|
|
|
|
mode := pomodoro.Mode
|
|
session := pomodoro.Session
|
|
sessions := pomodoro.PomodoroSettings.Sessions
|
|
|
|
switch mode {
|
|
case "Work":
|
|
duration = pomodoro.PomodoroSettings.Work
|
|
notification = fmt.Sprintf("Session %d/%d: %s %0.f minutes", session, sessions, mode, float32(duration)/60)
|
|
case "ShortBreak":
|
|
duration = pomodoro.PomodoroSettings.ShortBreak
|
|
notification = fmt.Sprintf("Session %d/%d: Take a %0.f minute break", session, sessions, float32(duration)/60)
|
|
case "LongBreak":
|
|
duration = pomodoro.PomodoroSettings.LongBreak
|
|
notification = fmt.Sprintf("Long Break: Take a %0.f minute break", float32(duration)/60)
|
|
case "End":
|
|
duration = 0
|
|
notification = fmt.Sprintf("Pomodoro sessions complete! Great job! 🎉")
|
|
}
|
|
|
|
if pomodoro.TimeLeft == duration { // start of segment
|
|
beeep.Alert("🍅 Pomodoro Timer", notification, "")
|
|
}
|
|
}
|