SNot/src/main.rs

30 lines
845 B
Rust
Raw Normal View History

2024-08-25 21:10:15 +00:00
use zbus::blocking::Connection;
use zbus::fdo::Result;
use zbus::Message;
use zbus::MatchRule;
fn main() -> Result<()> {
// Establish a connection to the session bus
let connection = Connection::session()?;
// Define a match rule for the notifications
let match_rule = MatchRule::builder()
.msg_type(zbus::MessageType::Signal)
.interface("org.freedesktop.Notifications")?
.path("/org/freedesktop/Notifications")?
.build();
2024-08-23 02:18:27 +00:00
// Add the match rule to the connection
2024-08-25 21:10:15 +00:00
connection.add_match(match_rule)?;
2024-08-20 04:56:36 +00:00
2024-08-25 21:10:15 +00:00
// Process notifications
loop {
2024-08-25 21:10:15 +00:00
let message = connection.receive_message()?;
if let Some(member) = message.member() {
if member.as_str() == "Notify" {
println!("Received a notification: {:?}", message);
}
}
}
}