File: progress.rs

package info (click to toggle)
rust-notify-rust 4.11.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 592 kB
  • sloc: sh: 18; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#[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() -> Result<(), Box<dyn std::error::Error>> {
    let mut notification = notify_rust::Notification::new()
        .summary("progress")
        .show()?;
    for i in 0..=10 {
        let value = i * 10;
        notification
            .body(&format!("progress {}%", value))
            .hint(notify_rust::Hint::CustomInt("value".to_string(), value));
        std::thread::sleep(std::time::Duration::from_secs(1));
        notification.update();
    }
    Ok(())
}