use zbus::{Connection, Result}; use futures_util::stream::TryStreamExt; #[tokio::main] async fn main() -> Result<()> { let connection = Connection::session().await?; connection .request_name("org.freedesktop.Notifications") // Requesting dbus for this service name. Any other services using this name should be stopped/disabled before this .await?; let mut stream = zbus::MessageStream::from(&connection); // Convert connection to a MessageStream, yields Message items while let Some(msg) = stream.try_next().await? { println!("{}", msg); let msg_header = msg.header(); dbg!(&msg); match msg_header.message_type() { zbus::message::Type::MethodCall => { // real code would check msg_header path(), interface() and member() // handle invalid calls, introspection, errors etc let body = msg.body(); let arg: &str = body.deserialize()?; println!("{}", arg); connection.reply(&msg, &(format!("Hello {}!", arg))).await?; // break; } _ => continue, } } Ok(()) }