Genesis
This commit is contained in:
commit
11c599a371
11 changed files with 325 additions and 0 deletions
35
internal/notifications/desktop.go
Normal file
35
internal/notifications/desktop.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package notifications
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"github.com/gen2brain/beeep"
|
||||
)
|
||||
|
||||
func DesktopNotifications(msg models.ServerMessage) {
|
||||
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, "")
|
||||
}
|
||||
}
|
37
internal/notifications/terminal.go
Normal file
37
internal/notifications/terminal.go
Normal file
|
@ -0,0 +1,37 @@
|
|||
package notifications
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
)
|
||||
|
||||
func TerminalOutput(msg models.ServerMessage) {
|
||||
var timerOutput string
|
||||
|
||||
fmt.Print("\033[H\033[2J") // Clears the screen
|
||||
|
||||
fmt.Printf("Work: %d | Break: %d | Longbreak: %d\n",
|
||||
msg.PomodoroSettings.Work/60,
|
||||
msg.PomodoroSettings.ShortBreak/60,
|
||||
msg.PomodoroSettings.LongBreak/60,
|
||||
)
|
||||
fmt.Printf("Session: %d/%d\n",
|
||||
msg.Session,
|
||||
msg.PomodoroSettings.Sessions,
|
||||
)
|
||||
fmt.Printf("\n▶ %s\n",
|
||||
msg.Mode,
|
||||
)
|
||||
|
||||
switch msg.Mode {
|
||||
case "Idle":
|
||||
timerOutput = ""
|
||||
default:
|
||||
minutes := msg.TimeLeft / 60
|
||||
seconds := msg.TimeLeft % 60
|
||||
|
||||
timerOutput = fmt.Sprintf("⏳ %02d:%02d", minutes, seconds)
|
||||
}
|
||||
|
||||
fmt.Printf(timerOutput)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue