| 1 | #[cfg(any(target_os = "windows", target_os = "macos"))] |
| 2 | fn main() { |
| 3 | println!("this is a xdg only feature") |
| 4 | } |
| 5 | |
| 6 | #[cfg(all(unix, not(target_os = "macos")))] |
| 7 | fn main() { |
| 8 | use notify_rust::*; |
| 9 | fn wait_for_keypress(msg: &str) { |
| 10 | println!("{}", msg); |
| 11 | std::io::stdin().read_line(&mut String::new()).unwrap(); |
| 12 | } |
| 13 | |
| 14 | let handle: NotificationHandle = Notification::new() |
| 15 | .summary("oh no") |
| 16 | .hint(Hint::Transient(true)) |
| 17 | .body("I'll be here till you close me!") |
| 18 | .hint(Hint::Resident(true)) // does not work on kde |
| 19 | .timeout(Timeout::Never) // works on kde and gnome |
| 20 | .show() |
| 21 | .unwrap(); |
| 22 | |
| 23 | wait_for_keypress("press to close notification"); |
| 24 | handle.close(); |
| 25 | wait_for_keypress("press to exit"); |
| 26 | } |