diff --git a/docs/meli.conf.5 b/docs/meli.conf.5 index 81383d46..cd9dafe9 100644 --- a/docs/meli.conf.5 +++ b/docs/meli.conf.5 @@ -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. diff --git a/src/components/notifications.rs b/src/components/notifications.rs index a28d99c9..cbc5fb89 100644 --- a/src/components/notifications.rs +++ b/src/components/notifications.rs @@ -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")) diff --git a/src/conf/notifications.rs b/src/conf/notifications.rs index 6502662a..d4c0bb3b 100644 --- a/src/conf/notifications.rs +++ b/src/conf/notifications.rs @@ -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, + + /// A command to pipe new mail notifications through (preferred over `script`). + /// Default: None + #[serde(default = "none")] + pub new_mail_script: Option, + /// 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, + #[serde(default = "internal_value_false", alias = "play-sound")] pub play_sound: ToggleFlag, + #[serde(default = "none", alias = "sound-file")] pub sound_file: Option, } @@ -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), diff --git a/src/conf/overrides.rs b/src/conf/overrides.rs index 344c2e0b..22e2bf64 100644 --- a/src/conf/overrides.rs +++ b/src/conf/overrides.rs @@ -214,12 +214,16 @@ pub struct NotificationsSettingsOverride { #[doc = " Default: True"] #[serde(default)] pub enable: Option, - #[doc = " A command to pipe notifications through"] + #[doc = " A command to pipe notifications through."] #[doc = " Default: None"] #[serde(default)] pub script: Option>, + #[doc = " A command to pipe new mail notifications through (preferred over `script`)."] + #[doc = " Default: None"] + #[serde(default)] + pub new_mail_script: Option>, #[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,