pub struct Notification {
summary: String,
body: Option<String>,
#[allow(dead_code)]
icon: Option<String>,
}
impl Notification {
pub fn new(summary: impl Into<String>) -> Self {
Self {
summary: summary.into(),
body: None,
icon: None,
}
}
pub fn body(mut self, body: impl Into<String>) -> Self {
self.body = Some(body.into());
self
}
pub fn icon(mut self, icon: impl Into<String>) -> Self {
self.icon = Some(icon.into());
self
}
pub fn show(self) -> bool {
#[cfg(feature = "notify-rust")]
{
let mut n = notify_rust::Notification::new();
n.summary(&self.summary);
if let Some(ref body) = self.body {
n.body(body);
}
n.show().is_ok()
}
#[cfg(not(feature = "notify-rust"))]
{
tracing::warn!("Notifications not available (notify-rust feature not enabled)");
false
}
}
}