From 1ea24e900d90b05b441c26487fad8aaa5a4e9244 Mon Sep 17 00:00:00 2001 From: candifloss Date: Wed, 28 Aug 2024 16:57:57 +0530 Subject: [PATCH] daily commit --- src/main.rs | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5861cba..005ea8d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,14 +51,15 @@ impl fmt::Display for Notif<'_> { )?; let actions_len = self.actions.len(); - let i = 0; + let mut i = 0; while i < actions_len { - let a:NotifAction; - a.action_id = &self.actions[i]; - a.action = &self.actions[i+1]; + let a = NotifAction { + action_id: &self.actions[i], + action: &self.actions[i+1], + }; println!("{a}"); - i += 1; + i += 2; }; writeln!(f, "Hints:")?; for (key, value) in &self.hints { @@ -66,8 +67,8 @@ impl fmt::Display for Notif<'_> { } match self.expir_timeout { -1 => writeln!(f, "None")?, - Some(millisec) => writeln!(f, "Expiration Timeout: {millisec}")?, - None => writeln!(f, "Error getting timeout")?, + _ => writeln!(f, "Expiration Timeout: {}", self.expir_timeout)?, + //None => writeln!(f, "Error getting timeout")?, } Ok(()) // Return Ok to indicate success } @@ -82,17 +83,6 @@ async fn main() -> Result<()> { // Establish a connection to the session bus let connection = Connection::session().await?; - // Create a match rule for the Notify signal - /*let match_rule = MatchRule::builder() - .msg_type(zbus::message::Type::Signal) - .sender("org.freedesktop.Notifications")? - .interface("org.freedesktop.Notifications")? - .arg_path(0, "/org/freedesktop/Notifications")? - .member("Notify")? - .build();*/ - - // Create a message iterator for the match rule - //let mut iterator = MessageIterator::for_match_rule(match_rule, &connection, None)?; // Loop to handle incoming messages loop { @@ -106,7 +96,6 @@ async fn main() -> Result<()> { // handle invalid calls, introspection, errors etc let arg: &str = msg.body()?; println!("Msg.body: {arg}"); - //connection.reply(&msg, &(format!("Hello {}!", arg)))?; } _ => continue, }