From 42fef3a7dd68fc6bf8f1ad8a0602bd5e4fef4482 Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Fri, 30 Oct 2020 18:07:37 -0500 Subject: [PATCH] Spawn xsetroot command on value update --- src/main.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0aaba48..a5b3c32 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,6 +3,7 @@ use dbus::blocking::stdintf::org_freedesktop_dbus::PropertiesPropertiesChanged; use dbus::blocking::Connection; use dbus::message::Message; use std::collections::HashMap; +use std::process::Command; use std::sync::{Arc, Mutex}; use std::time::Duration; @@ -36,9 +37,15 @@ fn update_map(arc_map: Arc>>, key: &str, val: &str let clone_arc = arc_map.clone(); let mut map = clone_arc.lock().unwrap(); map.insert(String::from(key), String::from(val)); - for (k, v) in &*map { - println! {"{}: {}", k.clone(), v.clone()}; - } + let _ = Command::new("xsetroot") + .arg("-name") + .arg(format!( + "[🔊 {title} - {artist}] | ✉ {unread_count}", + title = map.get("title").unwrap_or(&String::from("")), + artist = map.get("artist").unwrap_or(&String::from("")), + unread_count = map.get("unread_count").unwrap_or(&String::from("?")), + )) + .spawn(); } fn main() -> Result<(), Box> { -- 2.20.1