Erronous basic code structure. Needs corrections.

This commit is contained in:
Candifloss 2024-08-11 02:59:13 +05:30
parent cda876b5f2
commit 5a2c86bb63
2 changed files with 40 additions and 3 deletions

View File

@ -5,4 +5,7 @@ edition = "2021"
[dependencies] [dependencies]
zbus = "4.4.0" zbus = "4.4.0"
rson_rs = "*" rson_rs = "0.2.1"
tokio = {version = "^1.39.2", features = ["full"] }
futures = "0.3"
futures-util = "0.3"

View File

@ -1,3 +1,37 @@
fn main() { use zbus::{Connection, MessageStream, MatchRule, fdo};
println!("SNot!"); 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(())
} }