failed experiments
This commit is contained in:
parent
8bbdc51523
commit
2d32e1612e
27
src/main.rs
27
src/main.rs
@ -1,20 +1,33 @@
|
|||||||
|
use zbus::{Connection, Result};
|
||||||
use futures_util::stream::TryStreamExt;
|
use futures_util::stream::TryStreamExt;
|
||||||
use zbus::{Connection, MessageStream, Result};
|
|
||||||
use zvariant::{Type, Value};
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
let connection = Connection::session().await?;
|
let connection = Connection::session().await?;
|
||||||
connection
|
connection
|
||||||
.request_name("org.freedesktop.Notifications") // Requesting dbus for this service name
|
.request_name("org.freedesktop.Notifications") // Requesting dbus for this service name. Any other services using this name should be stopped/disabled before this
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Process incoming notifs
|
let mut stream = zbus::MessageStream::from(&connection); // Convert connection to a MessageStream, yields Message items
|
||||||
use futures_util::stream::TryStreamExt;
|
|
||||||
|
|
||||||
let mut stream = zbus::MessageStream::from(&connection); // Convert the connection into a message stream
|
|
||||||
while let Some(msg) = stream.try_next().await? {
|
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(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user