robin/utils/
notifications.rs1use anyhow::Result;
2use notify_rust::Notification;
3use std::process::Command;
4
5pub fn send_notification(title: &str, message: &str, success: bool) -> Result<()> {
6 if cfg!(target_os = "windows") {
7 let icon = if success { "✅" } else { "❌" };
8 let script = format!(
9 "New-BurntToastNotification -Text '{}', '{} {}' -Silent",
10 title, icon, message
11 );
12 Command::new("powershell")
13 .arg("-Command")
14 .arg(script)
15 .output()?;
16 } else {
17 let mut notification = Notification::new();
19
20 notification
21 .summary(title)
22 .body(&format!(
23 "{} {}",
24 if success { "✅" } else { "❌" },
25 message
26 ))
27 .timeout(5000); if cfg!(target_os = "macos") {
31 notification.sound_name("default");
32 } else {
33 notification.icon(if success { "dialog-ok" } else { "dialog-error" });
34 }
35
36 notification.show()?;
37 }
38 Ok(())
39}