From 8866dfc0984f1f7f917dfb6b5f0a165f42b446a1 Mon Sep 17 00:00:00 2001 From: Saiyed Shizain Date: Fri, 11 Sep 2026 19:09:45 +0530 Subject: feat: hot-reload theme when colors.json changes --- src/pomo/mod.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/pomo/mod.rs') diff --git a/src/pomo/mod.rs b/src/pomo/mod.rs index d1043e8..3a79d40 100644 --- a/src/pomo/mod.rs +++ b/src/pomo/mod.rs @@ -72,6 +72,24 @@ 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 != self.theme_mtime { + let (new_theme, new_mtime) = state::Theme::load_with_mtime(); + self.theme = new_theme; + self.theme_mtime = new_mtime; + } + } + } + pub fn save(&self) -> Result<(), Box> { let config = Config { work_time_mins: self.work_time.as_secs() / 60, @@ -127,6 +145,7 @@ impl Pomo { tokio::select! { _ = second_tick.tick() => { self.tick(); + self.check_theme_reload(); let _ = self.export_status(); } -- cgit v1.2.3