From 4d5604f7753e8c394f55371dd1b940181b7430f6 Mon Sep 17 00:00:00 2001 From: Skye Jensen Date: Mon, 15 Jun 2020 20:48:49 -0400 Subject: [PATCH] Add battery tile implemented by reading from /sys --- config.toml.example | 3 +++ src/config.rs | 2 ++ src/tiles/mod.rs | 2 ++ 3 files changed, 7 insertions(+) diff --git a/config.toml.example b/config.toml.example index 873a12e..2486e18 100644 --- a/config.toml.example +++ b/config.toml.example @@ -7,6 +7,9 @@ type = "memory" [[tile]] type = "hostname" +[[tile]] +type = "battery" + [[tile]] type = "time" format = "%Y-%m-%dT%H:%M:%S" diff --git a/src/config.rs b/src/config.rs index 72dca17..3fc7eae 100644 --- a/src/config.rs +++ b/src/config.rs @@ -52,6 +52,7 @@ pub struct TileConfig { #[derive(Deserialize, Clone, Debug)] #[serde(tag = "type", rename_all = "snake_case")] pub enum TileConfigType { + Battery, Memory, Load, Hostname, @@ -115,6 +116,7 @@ pub fn process_tile( ) -> BoxStream<'static, Result>> { let five_secs = Duration::from_secs(5); match &tile.config_type { + TileConfigType::Battery => wrap(tiles::battery_stream(), tile.update.or(Some(five_secs))), TileConfigType::Hostname => wrap(tiles::hostname_stream(), tile.update), TileConfigType::Load => wrap(tiles::load_stream(), tile.update.or(Some(five_secs))), TileConfigType::Memory => wrap(tiles::memory_stream(), tile.update.or(Some(five_secs))), diff --git a/src/tiles/mod.rs b/src/tiles/mod.rs index 13a4c8c..712cd85 100644 --- a/src/tiles/mod.rs +++ b/src/tiles/mod.rs @@ -1,7 +1,9 @@ +pub mod battery; pub mod hostname; pub mod load; pub mod memory; pub mod time; +pub use battery::battery_stream; pub use hostname::hostname_stream; pub use load::load_stream; pub use memory::memory_stream;