diff --git a/Cargo.toml b/Cargo.toml index a1363ab..d6d0bcf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,4 +5,7 @@ edition = "2021" [dependencies] zbus = "4.4.0" -rson_rs = "*" \ No newline at end of file +rson_rs = "0.2.1" +tokio = {version = "^1.39.2", features = ["full"] } +futures = "0.3" +futures-util = "0.3" \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 92776fa..1847a6b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,37 @@ -fn main() { - println!("SNot!"); +use zbus::{Connection, MessageStream, MatchRule, fdo}; +use zbus::zvariant::{OwnedValue, Type}; + +#[derive(Debug)] +struct Notification { + // ... fields +} + +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(()) }