2024-08-26 11:16:10 +00:00
|
|
|
//use zbus::blocking::Connection;
|
|
|
|
use zbus::Connection;
|
2024-08-25 21:10:15 +00:00
|
|
|
use zbus::fdo::Result;
|
|
|
|
use zbus::Message;
|
|
|
|
use zbus::MatchRule;
|
2024-08-26 11:16:10 +00:00
|
|
|
use zbus::blocking::Proxy;
|
|
|
|
use zbus::MessageStream;
|
|
|
|
//use futures_util::stream::TryStreamExt;
|
2024-08-25 21:10:15 +00:00
|
|
|
|
|
|
|
fn main() -> Result<()> {
|
|
|
|
// Establish a connection to the session bus
|
|
|
|
let connection = Connection::session()?;
|
|
|
|
|
2024-08-26 11:16:10 +00:00
|
|
|
// Proxy
|
|
|
|
let prox = Proxy::new(
|
|
|
|
&connection,
|
|
|
|
"org.freedesktop.Notifications", // Service/Bus name
|
|
|
|
"/org/freedesktop/Notifications", // Object path
|
|
|
|
"org.freedesktop.Notifications", // Interface name
|
|
|
|
)?;
|
|
|
|
|
2024-08-25 21:10:15 +00:00
|
|
|
// 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-26 11:16:10 +00:00
|
|
|
//connection.add_match(match_rule)?;
|
2024-08-20 04:56:36 +00:00
|
|
|
|
2024-08-26 11:16:10 +00:00
|
|
|
let mut stream = MessageStream::from(connection);
|
|
|
|
while let Some(msg) = stream.body? {
|
|
|
|
println!("Got message: {}", msg);
|
|
|
|
}
|
2024-08-25 21:10:15 +00:00
|
|
|
// Process notifications
|
2024-08-26 11:16:10 +00:00
|
|
|
/*loop {
|
|
|
|
/*
|
|
|
|
let message = connection.receive_signal()?;
|
2024-08-25 21:10:15 +00:00
|
|
|
if let Some(member) = message.member() {
|
|
|
|
if member.as_str() == "Notify" {
|
|
|
|
println!("Received a notification: {:?}", message);
|
|
|
|
}
|
2024-08-26 11:16:10 +00:00
|
|
|
} */
|
|
|
|
|
|
|
|
}*/
|
|
|
|
Ok(())
|
2024-08-11 19:12:21 +00:00
|
|
|
}
|