diff --git a/src/tiles/battery.rs b/src/tiles/battery.rs index 7fded58..ea9c1ed 100644 --- a/src/tiles/battery.rs +++ b/src/tiles/battery.rs @@ -19,6 +19,8 @@ pub async fn battery(config: BatteryConfig, output: OutputChannel) -> eyre::Resu let mut interval = tokio::time::interval(config.update); loop { + interval.tick().await; + let charge_now = async { let mut raw = String::new(); File::open(&now_path) @@ -56,7 +58,5 @@ pub async fn battery(config: BatteryConfig, output: OutputChannel) -> eyre::Resu ..Default::default() }) .await?; - - interval.tick().await; } } diff --git a/src/tiles/hostname.rs b/src/tiles/hostname.rs index 933720e..592bb5a 100644 --- a/src/tiles/hostname.rs +++ b/src/tiles/hostname.rs @@ -19,6 +19,8 @@ pub async fn hostname( ); let mut interval = tokio::time::interval(config.update); loop { + interval.tick().await; + let reply = proxy.hostname(); let hostname: String = reply.await?; output @@ -28,7 +30,5 @@ pub async fn hostname( ..Default::default() }) .await?; - - interval.tick().await; } } diff --git a/src/tiles/iwd.rs b/src/tiles/iwd.rs index d36eb5e..d8727b3 100644 --- a/src/tiles/iwd.rs +++ b/src/tiles/iwd.rs @@ -37,6 +37,8 @@ pub async fn iwd( let mut interval = tokio::time::interval(config.update); loop { + interval.tick().await; + let managed_objects = root_proxy.get_managed_objects().await?; let interface_path = get_interface_path(&managed_objects, &config.interface) .ok_or_eyre("Couldn't find interface")?; @@ -64,7 +66,5 @@ pub async fn iwd( ..Default::default() }) .await?; - - interval.tick().await; } } diff --git a/src/tiles/load.rs b/src/tiles/load.rs index 9b4e026..d3616ed 100644 --- a/src/tiles/load.rs +++ b/src/tiles/load.rs @@ -7,6 +7,8 @@ use tokio::io::AsyncReadExt; pub async fn load(config: LoadConfig, output: OutputChannel) -> eyre::Result<()> { let mut interval = tokio::time::interval(config.update); loop { + interval.tick().await; + let mut raw = String::new(); let mut file = File::open("/proc/loadavg").await?; file.read_to_string(&mut raw).await?; @@ -18,7 +20,5 @@ pub async fn load(config: LoadConfig, output: OutputChannel) -> eyre::Result<()> ..Default::default() }) .await?; - - interval.tick().await; } } diff --git a/src/tiles/local_time.rs b/src/tiles/local_time.rs index 64971f1..96da17f 100644 --- a/src/tiles/local_time.rs +++ b/src/tiles/local_time.rs @@ -38,10 +38,12 @@ async fn find_time_zone(config: LocalTimeConfig, sender: watch::Sender) - .build() .unwrap(); - let mut interval = tokio::time::interval(config.update_interval); let mut prev_addr = None; + let mut interval = tokio::time::interval(config.update_interval); loop { + interval.tick().await; + let curr_addr = if let Ok(curr_ipv6) = local_ip_address::local_ipv6() { Some(curr_ipv6) } else { @@ -61,8 +63,6 @@ async fn find_time_zone(config: LocalTimeConfig, sender: watch::Sender) - prev_addr = curr_addr; } } - - interval.tick().await; } } diff --git a/src/tiles/memory.rs b/src/tiles/memory.rs index b2c5058..78fa569 100644 --- a/src/tiles/memory.rs +++ b/src/tiles/memory.rs @@ -30,6 +30,8 @@ fn extract_value(line: &str) -> eyre::Result { pub async fn memory(config: MemoryConfig, output: OutputChannel) -> eyre::Result<()> { let mut interval = tokio::time::interval(config.update); loop { + interval.tick().await; + let mut raw = [0u8; 256]; let mut file = File::open("/proc/meminfo").await?; file.read_exact(&mut raw).await?; @@ -58,7 +60,5 @@ pub async fn memory(config: MemoryConfig, output: OutputChannel) -> eyre::Result ..Default::default() }) .await?; - - interval.tick().await; } }