Support notifications via terminal bell (#227)

Co-authored-by: Benjamin Grosse <ste3ls@gmail.com>
This commit is contained in:
Ulyssa 2024-03-24 10:19:34 -07:00 committed by GitHub
parent db9cb92737
commit 99996e275b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 78 additions and 27 deletions

View file

@ -86,6 +86,10 @@ fn is_profile_char(c: char) -> bool {
c.is_ascii_alphanumeric() || c == '.' || c == '-'
}
fn default_true() -> bool {
true
}
fn validate_profile_name(name: &str) -> bool {
if name.is_empty() {
return false;
@ -391,10 +395,24 @@ pub enum UserDisplayStyle {
DisplayName,
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "lowercase")]
pub enum NotifyVia {
/// Deliver notifications via terminal bell.
Bell,
/// Deliver notifications via desktop mechanism.
#[default]
Desktop,
}
#[derive(Clone, Debug, Default, Deserialize, Eq, PartialEq)]
pub struct Notifications {
#[serde(default)]
pub enabled: bool,
pub show_message: Option<bool>,
#[serde(default)]
pub via: NotifyVia,
#[serde(default = "default_true")]
pub show_message: bool,
}
#[derive(Clone)]