File: wait_for_closing_async.rs

package info (click to toggle)
rust-notify-rust 4.11.6-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 604 kB
  • sloc: sh: 18; makefile: 4
file content (26 lines) | stat: -rw-r--r-- 778 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#[cfg(any(target_os = "windows", target_os = "macos"))]
fn main() {
    println!("this is an xdg only feature")
}

#[cfg(all(unix, not(target_os = "macos")))]

fn main() {
    use notify_rust::CloseReason;

    zbus::block_on(async {
        let handle = notify_rust::Notification::new()
            .summary("Don't Mind me")
            .hint(notify_rust::Hint::Transient(true))
            .body("I'll be gone soon enough.\nSorry for the inconvenience.")
            .show_async()
            .await;

        match handle {
            Ok(handle) => handle.on_close(|reason: CloseReason| {
                println!("the notification was closed reason: {reason:?}")
            }),
            Err(error) => println!("failed to send notification {error}"),
        }
    })
}