aboutsummaryrefslogtreecommitdiff
path: root/src/pomo/mod.rs
diff options
context:
space:
mode:
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();
}