summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2022-08-28 17:34:53 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2022-08-28 17:39:20 +0300
commita42a6ca868e4590a8b93560737173e80993ecaec (patch)
treea88cb963d8920b4f03f39ef44017985e4947bb83
parentbde87af3877d4a0b071e331c93a07e0acf51bf7a (diff)
downloadmeli-a42a6ca868e4590a8b93560737173e80993ecaec.zip
notifications.rs: show notifications in terminal if no alternative
If no alternative (dbus or notification command) show notifications inside the terminal.
-rw-r--r--src/components/notifications.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/components/notifications.rs b/src/components/notifications.rs
index caf85f94..9c0fff00 100644
--- a/src/components/notifications.rs
+++ b/src/components/notifications.rs
@@ -190,6 +190,15 @@ impl Component for NotificationCommand {
fn process_event(&mut self, event: &mut UIEvent, context: &mut Context) -> bool {
if let UIEvent::Notification(ref title, ref body, ref kind) = event {
if context.settings.notifications.enable {
+ if *kind == Some(NotificationType::NewMail) {
+ if let Some(ref path) = context.settings.notifications.xbiff_file_path {
+ if let Err(err) = update_xbiff(path) {
+ debug!("Could not update xbiff file: {:?}", &err);
+ melib::log(format!("Could not update xbiff file: {}.", err), ERROR);
+ }
+ }
+ }
+
if let Some(ref bin) = context.settings.notifications.script {
match Command::new(bin)
.arg(&kind.map(|k| k.to_string()).unwrap_or_default())
@@ -223,6 +232,7 @@ impl Component for NotificationCommand {
{
Ok(child) => {
context.children.push(child);
+ return false;
}
Err(err) => {
log(
@@ -233,18 +243,19 @@ impl Component for NotificationCommand {
}
}
}
- }
- }
- if *kind == Some(NotificationType::NewMail) {
- if let Some(ref path) = context.settings.notifications.xbiff_file_path {
- if let Err(err) = update_xbiff(path) {
- debug!("Could not update xbiff file: {:?}", &err);
- melib::log(format!("Could not update xbiff file: {}.", err), ERROR);
- }
+ context
+ .replies
+ .push_back(UIEvent::StatusEvent(StatusEvent::DisplayMessage(format!(
+ "{title}{}{body}",
+ if title.is_some() { " " } else { "" },
+ title = title.as_deref().unwrap_or_default(),
+ body = body,
+ ))));
}
}
}
+
false
}
fn id(&self) -> ComponentId {