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
|
|
|
|
2024-08-25 20:37:59 +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
|
2024-08-25 20:37:59 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2024-08-25 20:37:59 +00:00
|
|
|
}
|
2024-08-11 19:12:21 +00:00
|
|
|
}
|