refactor: merge client/helper package to client
- remove helper package and move functions to client package
- merge `terminalOutput()` to `view.go`
- move `desktopNotifications()` to `cmd/client`
🤖
This commit is contained in:
parent
74f41f0e56
commit
b494c2782e
3 changed files with 67 additions and 76 deletions
39
cmd/client/notification.go
Normal file
39
cmd/client/notification.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/gen2brain/beeep"
|
||||
|
||||
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
)
|
||||
|
||||
// Send desktop notifications on the start of each segment
|
||||
func desktopNotifications(pomodoro GoTomato.ServerMessage) {
|
||||
var (
|
||||
duration int
|
||||
notification string
|
||||
)
|
||||
|
||||
mode := pomodoro.Mode
|
||||
session := pomodoro.Session
|
||||
sessions := pomodoro.Settings.Sessions
|
||||
|
||||
switch mode {
|
||||
case "Work":
|
||||
duration = pomodoro.Settings.Work
|
||||
notification = fmt.Sprintf("Session %d/%d: %s %0.f minutes", session, sessions, mode, float32(duration)/60)
|
||||
case "ShortBreak":
|
||||
duration = pomodoro.Settings.ShortBreak
|
||||
notification = fmt.Sprintf("Session %d/%d: Take a %0.f minute break", session, sessions, float32(duration)/60)
|
||||
case "LongBreak":
|
||||
duration = pomodoro.Settings.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, "")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue