diff --git a/cmd/client/main.go b/cmd/client/main.go index abf14ba..c4d9d91 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -29,15 +29,16 @@ func Start() { } go websocket.ProcessServerMessages(conn) + pomodoro := &shared.ServerMessage keyboard.Listen(func(key keys.Key) (stop bool, err error) { switch key.String() { case "space": - if !shared.ServerMessage.Ongoing { + if !pomodoro.Ongoing { websocket.SendCmd(conn, *password, "start") return false, nil } - if shared.ServerMessage.Paused { + if pomodoro.Paused { websocket.SendCmd(conn, *password, "resume") return false, nil } else { diff --git a/internal/notifications/desktop.go b/internal/notifications/desktop.go index ed27361..4b4c13d 100644 --- a/internal/notifications/desktop.go +++ b/internal/notifications/desktop.go @@ -7,31 +7,31 @@ import ( ) func DesktopNotifications() { - msg := &shared.ServerMessage - var duration int var notification string - mode := msg.Mode - session := msg.Session - sessions := msg.PomodoroSettings.Sessions + pomodoro := &shared.ServerMessage - switch msg.Mode { + mode := pomodoro.Mode + session := pomodoro.Session + sessions := pomodoro.PomodoroSettings.Sessions + + switch pomodoro.Mode { case "Work": - duration = msg.PomodoroSettings.Work + duration = pomodoro.PomodoroSettings.Work notification = fmt.Sprintf("Session %d/%d: %s %0.f minutes", session, sessions, mode, float32(duration)/60) case "ShortBreak": - duration = msg.PomodoroSettings.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 = msg.PomodoroSettings.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 msg.TimeLeft == duration { // start of segment + if pomodoro.TimeLeft == duration { // start of segment beeep.Alert("šŸ… Pomodoro Timer", notification, "") } } diff --git a/internal/notifications/terminal.go b/internal/notifications/terminal.go index ff380de..8a171be 100644 --- a/internal/notifications/terminal.go +++ b/internal/notifications/terminal.go @@ -9,29 +9,29 @@ import ( func TerminalOutput() { var timerOutput string - msg := &shared.ServerMessage + pomodoro := &shared.ServerMessage 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, + pomodoro.PomodoroSettings.Work/60, + pomodoro.PomodoroSettings.ShortBreak/60, + pomodoro.PomodoroSettings.LongBreak/60, ) fmt.Printf("Session: %d/%d\n", - msg.Session, - msg.PomodoroSettings.Sessions, + pomodoro.Session, + pomodoro.PomodoroSettings.Sessions, ) - fmt.Printf("\nā–¶ %s\n", - msg.Mode, + fmt.Printf("ā–¶ %s\n", + pomodoro.Mode, ) - switch msg.Mode { + switch pomodoro.Mode { case "Idle": timerOutput = "" default: - minutes := msg.TimeLeft / 60 - seconds := msg.TimeLeft % 60 + minutes := pomodoro.TimeLeft / 60 + seconds := pomodoro.TimeLeft % 60 timerOutput = fmt.Sprintf("ā³ %02d:%02d", minutes, seconds) }