diff options
Diffstat (limited to 'src/pomo/state.rs')
| -rw-r--r-- | src/pomo/state.rs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/pomo/state.rs b/src/pomo/state.rs index e224c9d..4c1772f 100644 --- a/src/pomo/state.rs +++ b/src/pomo/state.rs @@ -1,6 +1,7 @@ use ratatui::widgets::ListState; use std::time::Duration; use serde::{ Serialize, Deserialize }; +use notify_rust::Notification; #[derive(PartialEq, Clone, Copy)] pub enum SessionMode { Work, ShortBreak, LongBreak } @@ -67,8 +68,20 @@ impl Pomo { if self.is_running && self.time_remaining.as_secs() > 0 { self.time_remaining -= Duration::from_secs(1); } else if self.is_running && self.time_remaining.as_secs() == 0 { - self.is_running = false; + let (title, msg) = match self.mode { + SessionMode::Work => ( + "Focus Block Complete", + "I'm tired, boss." + ), + _ => ( + "Break Over", + "Ah shit, here we go again." + ), + }; + + self.send_notification(title, msg); self.transition_next_session(); + self.is_running = true; } } @@ -76,7 +89,7 @@ impl Pomo { match self.mode { SessionMode::Work => { self.break_count += 1; - if self.break_count % 4 == 0 { + if self.break_count % 3 == 0 { self.mode = SessionMode::LongBreak; self.time_remaining = self.long_break_time; self.total_duration = self.long_break_time; @@ -102,4 +115,13 @@ impl Pomo { }; self.total_duration = self.time_remaining; } + + pub fn send_notification(&self, title: &str, message: &str) { + let _ = Notification::new() + .summary(title) + .body(message) + .appname("pomoru") + .timeout(5000) + .show(); + } } |