| 1 | mod common; |
| 2 | |
| 3 | fn main() { |
| 4 | if !common::setup(file!()) { |
| 5 | return; |
| 6 | } |
| 7 | use notify_rust::{Notification, Timeout}; |
| 8 | |
| 9 | Notification::new() |
| 10 | .summary("click me") |
| 11 | .body("This will disappear by itself") |
| 12 | .action("clicked_a", "action") // IDENTIFIER, LABEL |
| 13 | // .hint(Hint::Transient(true)) // needed to work on kde |
| 14 | .show() |
| 15 | .unwrap() |
| 16 | .wait_for_action(|action| match action { |
| 17 | "clicked_a" => log::info!("clicked \"action\""), |
| 18 | // you don't have to match for this string if you use `wait_for_response` instead |
| 19 | "__closed" => log::info!("the notification was closed"), |
| 20 | _ => (), |
| 21 | }); |
| 22 | |
| 23 | Notification::new() |
| 24 | .summary("click me") |
| 25 | .body("This action needs to be clicked") |
| 26 | .action("default", "default") // IDENTIFIER, LABEL |
| 27 | .action("clicked_a", "button a") // IDENTIFIER, LABEL |
| 28 | .action("clicked_b", "button b") // IDENTIFIER, LABEL |
| 29 | .timeout(Timeout::Never) // works on kde and gnome |
| 30 | .show() |
| 31 | .unwrap() |
| 32 | .wait_for_action(|action| match action { |
| 33 | "default" => log::info!("default"), |
| 34 | "clicked_a" => log::info!("clicked a"), |
| 35 | "clicked_b" => log::info!("clicked b"), |
| 36 | "__closed" => log::info!("the notification was closed"), |
| 37 | _ => (), |
| 38 | }); |
| 39 | } |