aboutsummaryrefslogtreecommitdiff
path: root/src/pomo/mod.rs
diff options
context:
space:
mode:
authorSaiyed Shizain <saiyedshizain@gmail.com>2026-09-11 19:09:45 +0530
committerSaiyed Shizain <saiyedshizain@gmail.com>2026-09-11 19:09:45 +0530
commit8866dfc0984f1f7f917dfb6b5f0a165f42b446a1 (patch)
tree800fd322a188e1314b8d3c3307276f41e8bd4080 /src/pomo/mod.rs
parent5a90041da51c6813890b05a4bc1f9fcfe67c27de (diff)
downloadpomoru-8866dfc0984f1f7f917dfb6b5f0a165f42b446a1.tar.xz
pomoru-8866dfc0984f1f7f917dfb6b5f0a165f42b446a1.zip
feat: hot-reload theme when colors.json changes
Diffstat (limited to 'src/pomo/mod.rs')
-rw-r--r--src/pomo/mod.rs19
1 files changed, 19 insertions, 0 deletions
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<dyn std::error::Error>> {
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();
}