2024-08-10 21:29:13 +00:00
|
|
|
use zbus::{Connection, MessageStream, MatchRule, fdo};
|
|
|
|
use zbus::zvariant::{OwnedValue, Type};
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct Notification {
|
|
|
|
// ... fields
|
2024-08-10 21:45:37 +00:00
|
|
|
//
|
2024-08-10 21:29:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async fn main() -> Result<(), zbus::Error> {
|
|
|
|
let conn = Connection::new_session()?;
|
|
|
|
|
|
|
|
// Create a match rule to filter for notification signals
|
|
|
|
let match_rule = MatchRule::new_signal()
|
|
|
|
.interface("org.freedesktop.Notifications")
|
|
|
|
.member("Notify")
|
|
|
|
.build()?;
|
|
|
|
|
|
|
|
// Add the match rule to the connection
|
|
|
|
conn.add_match(&match_rule)?;
|
|
|
|
|
|
|
|
let stream = MessageStream::new(&conn)?;
|
|
|
|
|
|
|
|
while let Some(msg) = stream.next().await? {
|
|
|
|
// Extract notification data from the message
|
|
|
|
// ...
|
|
|
|
|
|
|
|
// Create a Notification struct
|
|
|
|
let notification = Notification {
|
|
|
|
// ...
|
|
|
|
};
|
|
|
|
|
|
|
|
// Handle the notification
|
|
|
|
println!("Received notification: {:?}", notification);
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(())
|
2024-08-09 14:40:05 +00:00
|
|
|
}
|