From d0a2cc22c08f8e5058061bcfcf0c6b3d671685e1 Mon Sep 17 00:00:00 2001 From: Vladimir Rubin Date: Sat, 14 Jun 2025 20:46:34 +0300 Subject: [PATCH] fix: build error on nix this happened because nixpkgs doens't yet have the latest nightly rust --- src/main.rs | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8cafccf..ceb1244 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,23 +34,24 @@ async fn config_reloader(notify: Arc) { loop { trace!("config poll tick"); let config_path = get_config_path(); - if config_path.exists() - && let Ok(current_modified) = std::fs::metadata(&config_path) + if config_path.exists() { + if let Ok(current_modified) = std::fs::metadata(&config_path) .and_then(|m| m.modified()) .map(|t| t.duration_since(UNIX_EPOCH).unwrap().as_secs()) - { - let last: u64 = LAST_MODIFIED.load(Ordering::SeqCst); - if 0 != last { - if current_modified > last { - trace!("{current_modified}"); - trace!("{last}"); - debug!("Config file modified, reloading..."); + { + let last: u64 = LAST_MODIFIED.load(Ordering::SeqCst); + if 0 != last { + if current_modified > last { + trace!("{current_modified}"); + trace!("{last}"); + debug!("Config file modified, reloading..."); + reload_config(Arc::clone(¬ify)).await; + } + } else { + // File is new, reload to capture initial state + debug!("Config file detected, reloading..."); reload_config(Arc::clone(¬ify)).await; } - } else { - // File is new, reload to capture initial state - debug!("Config file detected, reloading..."); - reload_config(Arc::clone(¬ify)).await; } } sleep(Duration::from_secs(5)).await; @@ -136,14 +137,20 @@ async fn socket_server( let now = !disabled_temp.load(Ordering::SeqCst); disabled_temp.store(now, Ordering::SeqCst); notify.notify_one(); - debug!("temp dimming is {}", if now { "enabled" } else { "disabled" }); + debug!( + "temp dimming is {}", + if now { "enabled" } else { "disabled" } + ); } "toggle_gamma" => { trace!("toggle_gamma dispatched"); let now = !disabled_gamma.load(Ordering::SeqCst); disabled_gamma.store(now, Ordering::SeqCst); notify.notify_one(); - debug!("gamma dimming is {}", if now { "enabled" } else { "disabled" }); + debug!( + "gamma dimming is {}", + if now { "enabled" } else { "disabled" } + ); } "toggle" => { trace!("toggle dispatched");