ChronoTomato/internal/notifications/desktop.go
Sebastian Mark 064056e8cb feat: update module path
- modify go.mod to reflect the new module path
- update config file path in the main function
- adjust import statements in various internal packages
- add install instructions to README

🤖
2024-10-23 21:21:23 +02:00

37 lines
1.1 KiB
Go

package notifications
import (
"git.smsvc.net/pomodoro/ChronoTomato/internal/shared"
"fmt"
"github.com/gen2brain/beeep"
)
func DesktopNotifications() {
var duration int
var notification string
pomodoro := &shared.ServerMessage
mode := pomodoro.Mode
session := pomodoro.Session
sessions := pomodoro.PomodoroSettings.Sessions
switch pomodoro.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, "")
}
}