SNot/src/main.rs

40 lines
947 B
Rust
Raw Normal View History

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 22:11:05 +00:00
#[tokio::main]
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
}