File: countdown.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 (34 lines) | stat: -rw-r--r-- 853 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
27
28
29
30
31
32
33
34
#![allow(unused_imports, dead_code)]
use notify_rust::Notification;
use std::time::Duration;

#[cfg(any(target_os = "windows", target_os = "macos"))]
fn main() {
    println!("this is a xdg only feature")
}

#[cfg(all(unix, not(target_os = "macos")))]
fn main() {
    let mut notification = Notification::new()
        .summary("Rocket launch in ...")
        .body("count down")
        .icon("clock")
        .timeout(0)
        .show()
        .unwrap();

    for i in 0..11 {
        std::thread::sleep(Duration::from_millis(1_000));
        notification
            .body(&format!("T-minus {}", 10 - i))
            .appname(&format!("countdown_{}", 10 - i));
        notification.update();
        println!("{}", 10 - i);
    }

    notification
        .body("TAKE OFF")
        .appname("countdown_takeoff")
        .show()
        .unwrap();
}