2024-11-13 08:43:58 +00:00
|
|
|
package client
|
2024-10-22 11:13:41 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/gen2brain/beeep"
|
2024-10-27 20:34:53 +00:00
|
|
|
|
|
|
|
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
2024-10-22 11:13:41 +00:00
|
|
|
)
|
|
|
|
|
2024-10-30 10:03:18 +00:00
|
|
|
// Send desktop notifications on the start of each segment
|
2024-11-13 08:43:58 +00:00
|
|
|
func desktopNotifications(pomodoro GoTomato.ServerMessage) {
|
2024-10-27 20:32:57 +00:00
|
|
|
var (
|
|
|
|
duration int
|
|
|
|
notification string
|
|
|
|
)
|
2024-10-22 11:13:41 +00:00
|
|
|
|
2024-10-23 11:48:16 +00:00
|
|
|
mode := pomodoro.Mode
|
|
|
|
session := pomodoro.Session
|
2024-10-28 06:56:37 +00:00
|
|
|
sessions := pomodoro.Settings.Sessions
|
2024-10-22 11:13:41 +00:00
|
|
|
|
2024-10-24 20:33:11 +00:00
|
|
|
switch mode {
|
2024-10-22 11:13:41 +00:00
|
|
|
case "Work":
|
2024-10-28 06:56:37 +00:00
|
|
|
duration = pomodoro.Settings.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":
|
2024-10-28 06:56:37 +00:00
|
|
|
duration = pomodoro.Settings.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":
|
2024-10-28 06:56:37 +00:00
|
|
|
duration = pomodoro.Settings.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! 🎉")
|
|
|
|
}
|
|
|
|
|
2024-10-23 11:48:16 +00:00
|
|
|
if pomodoro.TimeLeft == duration { // start of segment
|
2024-10-22 11:13:41 +00:00
|
|
|
beeep.Alert("🍅 Pomodoro Timer", notification, "")
|
|
|
|
}
|
|
|
|
}
|