aboutsummaryrefslogtreecommitdiff
path: root/crates/dinggerd/src/notify.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/dinggerd/src/notify.rs')
-rw-r--r--crates/dinggerd/src/notify.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/dinggerd/src/notify.rs b/crates/dinggerd/src/notify.rs
index e619d6d..555299d 100644
--- a/crates/dinggerd/src/notify.rs
+++ b/crates/dinggerd/src/notify.rs
@@ -63,6 +63,19 @@ pub fn play_sound(kind: &NotificationKind) {
}
}
+/// Deliver a notification and wait for it: for short-lived commands, whose
+/// exit would cut a background delivery short.
+pub fn send_message_blocking(title: &str, body: &str) {
+ info!(title, body, "notifying");
+ if let Ok(command) = std::env::var("DINGGER_NOTIFIER") {
+ let _ = std::process::Command::new("sh").args(["-c", &command, title, body]).status();
+ return;
+ }
+ if let Err(err) = mac_notification_sys::Notification::new().title(title).message(body).send() {
+ warn!(%err, "failed to deliver macOS notification");
+ }
+}
+
/// Deliver a macOS notification without blocking the caller: the delivery
/// call waits on Notification Center for seconds, and the watcher must keep
/// updating the UI meanwhile.