Pomodoro CLI Timer
A minimalist, yet powerful productivity tool built in Go.
Overview
The Pomodoro CLI Timer is a command-line application crafted with Go that brings the efficiency of the Pomodoro Technique right to your terminal. By cycling between focused work sessions and rejuvenating breaks, this tool is engineered to help users maintain their productivity without distraction. It serves as both a practical utility and a demonstration of modern, event-driven TUI (Text-based User Interface) design using the Bubble Tea framework.
Key Features
-
Session Management:
Seamlessly shifts between work sessions, short breaks, and long breaks. After every four work sessions, the tool automatically initiates a long break, ensuring optimized productivity cycles. -
Interactive Terminal UI:
Built with Bubble Tea and styled via Lip Gloss, the interface offers a dynamic progress bar and clear session indicators. Real-time updates provide immediate visual feedback on your remaining time. -
System Notifications:
Utilizing the toast library, the application sends Windows notifications to alert you when a session or break concludes. Future updates plan to integrate alternative libraries for broader cross-platform support. -
Simple Keyboard Controls:
Execute essential commands effortlessly:- Spacebar: Pause or resume the timer.
- R key: Reset the current timer.
- Q or Ctrl+C: Quit the application.
Technical Details
The project leverages Go’s strong concurrency model alongside the Bubble Tea architecture to manage state and tick messages effectively. The timer updates every second using an event-driven approach. Here’s a brief glimpse of the core timer mechanism and session-handling logic:
// Timer command: Emits a tick message every second to drive updates.
func timerCmd() tea.Cmd {
return tea.Tick(time.Second, func(t time.Time) tea.Msg {
return tickMsg{}
})
}
// Update function handles key events and ticking logic.
func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
switch msg.String() {
case " ":
m.isRunning = !m.isRunning
if m.isRunning {
return m, timerCmd()
}
return m, nil
case "q", "ctrl+c":
return m, tea.Quit
case "r":
m.resetTimer()
return m, nil
}
case tickMsg:
if m.isRunning {
m.remaining -= time.Second
// Update progress based on total duration.
m.progress = float64(m.totalDuration-m.remaining) / float64(m.totalDuration)
// Session-switching logic with notifications.
if m.remaining <= 0 {
switch m.currentSession {
case work:
m.workCount++
showNotification("Pomodoro", "Work session completed!")
if m.workCount%4 == 0 {
m.currentSession = longBreak
m.remaining = 15 * time.Minute
} else {
m.currentSession = shortBreak
m.remaining = 5 * time.Minute
}
case shortBreak, longBreak:
showNotification("Pomodoro", "Break is over!")
m.currentSession = work
m.remaining = 25 * time.Minute
}
m.progress = 0.0
}
return m, timerCmd()
}
}
return m, nil
}
Project Impact
This project not only consolidates my proficiency in Go and modern CLI development but also reflects a commitment to elegant, user-focused design. By blending real-time progress visualization with automated session management and system notifications, the Pomodoro CLI Timer is a fine example of how thoughtful design can elevate simple tools into indispensable productivity aids.
Whether you’re a potential employer or a fellow developer, this project showcases my ability to tackle challenges head-on with efficient code and intuitive interfaces. I’m eager to bring this same drive and attention to detail to future projects and collaborative environments.