ChronoTomato/internal/notifications/desktop.go

38 lines
1 KiB
Go
Raw Normal View History

2024-10-22 11:13:41 +00:00
package notifications
import (
"ChronoTomato/internal/shared"
2024-10-22 11:13:41 +00:00
"fmt"
"github.com/gen2brain/beeep"
)
func DesktopNotifications() {
2024-10-22 11:13:41 +00:00
var duration int
var notification string
pomodoro := &shared.ServerMessage
mode := pomodoro.Mode
session := pomodoro.Session
sessions := pomodoro.PomodoroSettings.Sessions
2024-10-22 11:13:41 +00:00
switch pomodoro.Mode {
2024-10-22 11:13:41 +00:00
case "Work":
duration = pomodoro.PomodoroSettings.Work
2024-10-22 11:13:41 +00:00
notification = fmt.Sprintf("Session %d/%d: %s %0.f minutes", session, sessions, mode, float32(duration)/60)
case "ShortBreak":
duration = pomodoro.PomodoroSettings.ShortBreak
2024-10-22 11:13:41 +00:00
notification = fmt.Sprintf("Session %d/%d: Take a %0.f minute break", session, sessions, float32(duration)/60)
case "LongBreak":
duration = pomodoro.PomodoroSettings.LongBreak
2024-10-22 11:13:41 +00:00
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
2024-10-22 11:13:41 +00:00
beeep.Alert("🍅 Pomodoro Timer", notification, "")
}
}