From 398cd96934b1c3f3d68b1844bce5e42e21901238 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Sat, 30 Jan 2021 10:34:31 -0500 Subject: [PATCH] omg colors Signed-off-by: Christine Dodrill --- src/bin/cabytcinysuhei.rs | 11 +++++++++++ src/lib.rs | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/bin/cabytcinysuhei.rs b/src/bin/cabytcinysuhei.rs index 9661b16..2614520 100644 --- a/src/bin/cabytcinysuhei.rs +++ b/src/bin/cabytcinysuhei.rs @@ -39,6 +39,15 @@ fn main() -> Result<()> { let data = mtst.lock().unwrap(); let mut blocks: Vec = vec![Block { full_text: data.front.clone(), + color: match data.front.as_str() { + "Cadey" => Some("#F86AF3".to_string()), + "Nicole" => Some("#C79DD7".to_string()), + "Jessie" => Some("#97871A".to_string()), + "Ashe" => Some("#458588".to_string()), + "Sephie" => Some("#D79921".to_string()), + "Mai" => Some("#D65D0E".to_string()), + _ => None, + }, }]; if let Some(datni) = &data.weather { @@ -50,11 +59,13 @@ fn main() -> Result<()> { datni.daily.data[0].temperature_high, datni.daily.data[0].temperature_low ), + color: None, }) } blocks.push(Block { full_text: Local::now().format("%H:%M M%m %-d %a").to_string(), + color: None, }); println!(",{}", serde_json::to_string(&blocks)?); diff --git a/src/lib.rs b/src/lib.rs index 3ae269d..9eab9c6 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -29,9 +29,10 @@ pub struct State { pub weather: Option, } -#[derive(Serialize)] +#[derive(Serialize, Default)] pub struct Block { pub full_text: String, + pub color: Option, } impl fmt::Display for State {