summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-15 23:37:14 +0300
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-09-15 23:38:32 +0300
commit86f21fbe528083d95ef93e9c92fd9fd4564990be (patch)
tree166cbbeae7d37e857dc4bbec4ca992ce44348d82
parentbd8424c1f894ae0d1b8bf8f2893c4bd8795446b9 (diff)
ui: xbiff(1) support
-rw-r--r--ui/src/components/notifications.rs16
-rw-r--r--ui/src/conf/notifications.rs5
2 files changed, 21 insertions, 0 deletions
diff --git a/ui/src/components/notifications.rs b/ui/src/components/notifications.rs
index 706275bd..8f9b11c1 100644
--- a/ui/src/components/notifications.rs
+++ b/ui/src/components/notifications.rs
@@ -152,6 +152,22 @@ impl Component for NotificationFilter {
debug!("{:?}", v);
}
}
+
+ match kind {
+ Some(NotificationType::NewMail) => {
+ if let Some(ref path) = context.runtime_settings.notifications.xbiff_file_path {
+ let mut file = std::fs::OpenOptions::new().append(true) /* writes will append to a file instead of overwriting previous contents */
+ .create(true) /* a new file will be created if the file does not yet already exist.*/
+ .open(path).unwrap();
+ if file.metadata().unwrap().len() > 128 {
+ file.set_len(0).unwrap();
+ } else {
+ std::io::Write::write_all(&mut file, b"z").unwrap();
+ }
+ }
+ }
+ _ => {}
+ }
}
false
}
diff --git a/ui/src/conf/notifications.rs b/ui/src/conf/notifications.rs
index c450e2b4..beeac081 100644
--- a/ui/src/conf/notifications.rs
+++ b/ui/src/conf/notifications.rs
@@ -33,6 +33,11 @@ pub struct NotificationsSettings {
/// Default: None
#[serde(default = "none")]
pub script: Option<String>,
+ /// A file location which has its size changed when new mail arrives (max 128 bytes). Can be
+ /// used to trigger new mail notifications eg with `xbiff(1)`
+ /// Default: None
+ #[serde(default = "none")]
+ pub xbiff_file_path: Option<String>,
#[serde(deserialize_with = "toggleflag_de", default = "internal_value_false")]
pub play_sound: super::ToggleFlag,
#[serde(default = "none")]