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