use std::collections::HashMap; use zbus::blocking::{Connection, MessageIterator}; use zbus::fdo::Result; use zbus::zvariant::Value; use zbus::MatchRule; fn main() -> Result<()> { // Establish a connection to the session bus let connection = Connection::session()?; // Create a match rule for the Notify signal let match_rule = MatchRule::builder() .msg_type(zbus::message::Type::Signal) .interface("org.freedesktop.Notifications")? .member("Notify")? .build(); // Create a message iterator for the match rule let mut iterator = MessageIterator::for_match_rule(match_rule, &connection, None)?; // Loop to handle incoming messages while let Some(result) = iterator.next() { match result { Ok(msg) => { // Extract the body of the message let body_result: Result<(String, u32, String, String, String, Vec, HashMap, i32), _> = msg.body(); match body_result { Ok((app_name, id, summary, body, icon, actions, hints, timeout)) => { println!("Got notification:"); println!(" App Name: {}", app_name); println!(" ID: {}", id); println!(" Summary: {}", summary); println!(" Body: {}", body); println!(" Icon: {}", icon); println!(" Actions: {:?}", actions); println!(" Hints: {:?}", hints); println!(" Timeout: {}", timeout); }, Err(e) => println!("Error decoding message body: {:?}", e), } } Err(e) => println!("Error receiving message: {:?}", e), } } Ok(()) }