File: mac_app_id.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 (35 lines) | stat: -rw-r--r-- 962 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
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#[cfg(target_os = "macos")]
fn main() -> Result<(), String> {
    use notify_rust::{
        error::MacOsError, get_bundle_identifier_or_default, set_application, Notification,
    };

    let safari_id = get_bundle_identifier_or_default("Safari");
    set_application(&safari_id).map_err(|f| format!("{}", f))?;

    match set_application(&safari_id) {
        Ok(_) => {}
        Err(MacOsError::Application(error)) => println!("{}", error),
        Err(MacOsError::Notification(error)) => println!("{}", error),
    }

    Notification::new()
        .summary("Safari Crashed")
        .body("Just kidding, this is just the notify_rust example.")
        .appname("Safari")
        .icon("Safari")
        .show()
        .map_err(|f| format!("{}", f))?;

    Ok(())
}

#[cfg(all(unix, not(target_os = "macos")))]
fn main() {
    println!("this is a mac only feature")
}

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