aboutsummaryrefslogtreecommitdiff
path: root/src/pomo/state.rs
diff options
context:
space:
mode:
authorSaiyed Shizain <saiyedshizain@gmail.com>2026-01-19 02:11:12 +0530
committerSaiyed Shizain <saiyedshizain@gmail.com>2026-01-19 02:11:12 +0530
commitf2293afdfc4d67257daf0838db90e029dda485bd (patch)
tree42548b1e6c4506124abd49a4c4931c553cefe6e8 /src/pomo/state.rs
parentdcd61c807d95fd5ccd0d106865122788e7322fc8 (diff)
downloadpomoru-f2293afdfc4d67257daf0838db90e029dda485bd.tar.xz
pomoru-f2293afdfc4d67257daf0838db90e029dda485bd.zip
add notifications
ui fix: 3 was looking like 8 in timer logic update: every third break is a long break
Diffstat (limited to 'src/pomo/state.rs')
-rw-r--r--src/pomo/state.rs26
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();
+ }
}