notifications: add new_mail_script option
Preferred over `script` option for new email notificationsissue-133
parent
d8d43a16fe
commit
0ed10711ef
|
@ -990,8 +990,14 @@ Enable notifications.
|
|||
.Pq Em optional
|
||||
Script to pass notifications to, with title as 1st arg and body as 2nd
|
||||
.\" default value
|
||||
.Pq Em none Ns
|
||||
\&.
|
||||
.Pq Em none
|
||||
.It Ic new_mail_script Ar String
|
||||
.Pq Em optional
|
||||
A command to pipe new mail notifications through (preferred over
|
||||
.Ic script Ns
|
||||
), with title as 1st arg and body as 2nd.
|
||||
.\" default value
|
||||
.Pq Em none
|
||||
.It Ic xbiff_file_path Ar String
|
||||
.Pq Em optional
|
||||
File that gets its size updated when new mail arrives.
|
||||
|
|
|
@ -200,7 +200,14 @@ impl Component for NotificationCommand {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(ref bin) = context.settings.notifications.script {
|
||||
let mut script = context.settings.notifications.script.as_ref();
|
||||
if *kind == Some(NotificationType::NewMail)
|
||||
&& context.settings.notifications.new_mail_script.is_some()
|
||||
{
|
||||
script = context.settings.notifications.new_mail_script.as_ref();
|
||||
}
|
||||
|
||||
if let Some(ref bin) = script {
|
||||
match Command::new(bin)
|
||||
.arg(&kind.map(|k| k.to_string()).unwrap_or_default())
|
||||
.arg(title.as_ref().map(String::as_str).unwrap_or("meli"))
|
||||
|
|
|
@ -31,17 +31,26 @@ pub struct NotificationsSettings {
|
|||
/// Default: True
|
||||
#[serde(default = "true_val")]
|
||||
pub enable: bool,
|
||||
/// A command to pipe notifications through
|
||||
|
||||
/// A command to pipe notifications through.
|
||||
/// Default: None
|
||||
#[serde(default = "none")]
|
||||
pub script: Option<String>,
|
||||
|
||||
/// A command to pipe new mail notifications through (preferred over `script`).
|
||||
/// Default: None
|
||||
#[serde(default = "none")]
|
||||
pub new_mail_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)`
|
||||
/// used to trigger new mail notifications eg with `xbiff(1)`.
|
||||
/// Default: None
|
||||
#[serde(default = "none", alias = "xbiff-file-path")]
|
||||
pub xbiff_file_path: Option<String>,
|
||||
|
||||
#[serde(default = "internal_value_false", alias = "play-sound")]
|
||||
pub play_sound: ToggleFlag,
|
||||
|
||||
#[serde(default = "none", alias = "sound-file")]
|
||||
pub sound_file: Option<String>,
|
||||
}
|
||||
|
@ -51,6 +60,7 @@ impl Default for NotificationsSettings {
|
|||
Self {
|
||||
enable: true,
|
||||
script: None,
|
||||
new_mail_script: None,
|
||||
xbiff_file_path: None,
|
||||
play_sound: ToggleFlag::InternalVal(false),
|
||||
sound_file: None,
|
||||
|
@ -65,6 +75,7 @@ impl DotAddressable for NotificationsSettings {
|
|||
match *field {
|
||||
"enable" => self.enable.lookup(field, tail),
|
||||
"script" => self.script.lookup(field, tail),
|
||||
"new_mail_script" => self.new_mail_script.lookup(field, tail),
|
||||
"xbiff_file_path" => self.xbiff_file_path.lookup(field, tail),
|
||||
"play_sound" => self.play_sound.lookup(field, tail),
|
||||
"sound_file" => self.sound_file.lookup(field, tail),
|
||||
|
|
|
@ -214,12 +214,16 @@ pub struct NotificationsSettingsOverride {
|
|||
#[doc = " Default: True"]
|
||||
#[serde(default)]
|
||||
pub enable: Option<bool>,
|
||||
#[doc = " A command to pipe notifications through"]
|
||||
#[doc = " A command to pipe notifications through."]
|
||||
#[doc = " Default: None"]
|
||||
#[serde(default)]
|
||||
pub script: Option<Option<String>>,
|
||||
#[doc = " A command to pipe new mail notifications through (preferred over `script`)."]
|
||||
#[doc = " Default: None"]
|
||||
#[serde(default)]
|
||||
pub new_mail_script: Option<Option<String>>,
|
||||
#[doc = " A file location which has its size changed when new mail arrives (max 128 bytes). Can be"]
|
||||
#[doc = " used to trigger new mail notifications eg with `xbiff(1)`"]
|
||||
#[doc = " used to trigger new mail notifications eg with `xbiff(1)`."]
|
||||
#[doc = " Default: None"]
|
||||
#[serde(alias = "xbiff-file-path")]
|
||||
#[serde(default)]
|
||||
|
@ -236,6 +240,7 @@ impl Default for NotificationsSettingsOverride {
|
|||
NotificationsSettingsOverride {
|
||||
enable: None,
|
||||
script: None,
|
||||
new_mail_script: None,
|
||||
xbiff_file_path: None,
|
||||
play_sound: None,
|
||||
sound_file: None,
|
||||
|
|
Loading…
Reference in New Issue