aboutsummaryrefslogtreecommitdiff
path: root/src/pomo/mod.rs
diff options
context:
space:
mode:
authorSaiyed Shizain <saiyedshizain@gmail.com>2026-09-11 23:53:29 +0530
committerGitHub <noreply@github.com>2026-09-11 23:53:29 +0530
commit8672d041bec1a3c80da95adbfb5d0f974a97f84b (patch)
tree41c5a0e5e6bcf13b1aa895ab3260a471824d4901 /src/pomo/mod.rs
parent978bdc8d8a1a4dd50e1f539d89764a44d995a2d2 (diff)
parentb885efbf21f2839318a46e484654e706821b716e (diff)
downloadpomoru-1.2.0.tar.xz
pomoru-1.2.0.zip
Merge pull request #9 from RanXom/feat/hot-reload-themev1.2.0
Feat/hot-reload-theme: Noctalia v5 (matugen) theming support & smooth hot-reloading
Diffstat (limited to 'src/pomo/mod.rs')
-rw-r--r--src/pomo/mod.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs
index d1043e8..2ccecbb 100644
--- a/src/pomo/mod.rs
+++ b/src/pomo/mod.rs
@@ -72,6 +72,26 @@ impl Pomo {
Ok(())
}
+ pub fn check_theme_reload(&mut self) {
+ if let Some(base_dirs) = directories::BaseDirs::new() {
+ let matugen_path = base_dirs.home_dir().join(".cache/pomoru/colors.json");
+ let legacy_path = base_dirs.home_dir().join(".config/noctalia/colors.json");
+
+ let current_mtime = fs::metadata(&matugen_path)
+ .or_else(|_| fs::metadata(&legacy_path))
+ .and_then(|m| m.modified())
+ .ok();
+
+ if current_mtime.is_some() && current_mtime != self.theme_mtime {
+ let (new_theme, new_mtime) = state::Theme::load_with_mtime();
+ if new_mtime.is_some() {
+ self.theme = new_theme;
+ self.theme_mtime = new_mtime;
+ }
+ }
+ }
+ }
+
pub fn save(&self) -> Result<(), Box<dyn std::error::Error>> {
let config = Config {
work_time_mins: self.work_time.as_secs() / 60,
@@ -118,6 +138,7 @@ impl Pomo {
let mut terminal = Terminal::new(backend)?;
let mut second_tick = tokio::time::interval(Duration::from_secs(1));
+ let mut theme_tick = tokio::time::interval(Duration::from_millis(100));
let _ = self.export_status();
@@ -130,6 +151,10 @@ impl Pomo {
let _ = self.export_status();
}
+ _ = theme_tick.tick() => {
+ self.check_theme_reload();
+ }
+
// Tighten poll to 16ms (~60fps feel) for input responsiveness
event_res = tokio::task::spawn_blocking(|| event::poll(Duration::from_millis(16))) => {
if let Ok(Ok(true)) = event_res