Erronous basic code structure. Needs corrections.
This commit is contained in:
parent
cda876b5f2
commit
5a2c86bb63
@ -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"
|
38
src/main.rs
38
src/main.rs
@ -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(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user