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")
}
|