ui: xbiff(1) support

master
Manos Pitsidianakis 2019-09-15 23:37:14 +03:00
parent bd8424c1f8
commit 86f21fbe52
Signed by: Manos Pitsidianakis
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);
}
}
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
}

View File

@ -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")]