ui: xbiff(1) support

This commit is contained in:
Manos Pitsidianakis 2019-09-15 23:37:14 +03:00
parent bd8424c1f8
commit 86f21fbe52
No known key found for this signature in database
GPG Key ID: 73627C2F690DF710
2 changed files with 21 additions and 0 deletions

View File

@ -152,6 +152,22 @@ impl Component for NotificationFilter {
debug!("{:?}", v); 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 false
} }

View File

@ -33,6 +33,11 @@ pub struct NotificationsSettings {
/// Default: None /// Default: None
#[serde(default = "none")] #[serde(default = "none")]
pub script: Option<String>, 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")] #[serde(deserialize_with = "toggleflag_de", default = "internal_value_false")]
pub play_sound: super::ToggleFlag, pub play_sound: super::ToggleFlag,
#[serde(default = "none")] #[serde(default = "none")]