diff options
author | fxqnlr <[email protected]> | 2024-09-25 15:22:14 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-25 15:22:14 +0200 |
commit | 5f23d5506698081722eef6e34f11c7fb24e0b212 (patch) | |
tree | e106511c745f47ee71fd8f0eed284cdddf57241b /src/main.rs | |
parent | 91730bcecda6f2e7ef5e10983d6b0ce0b38196ab (diff) | |
download | arbs-5f23d5506698081722eef6e34f11c7fb24e0b212.tar arbs-5f23d5506698081722eef6e34f11c7fb24e0b212.tar.gz arbs-5f23d5506698081722eef6e34f11c7fb24e0b212.zip |
fix no notifications
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index ab23ab7..dad98c6 100644 --- a/src/main.rs +++ b/src/main.rs | |||
@@ -3,7 +3,6 @@ use clap::Parser; | |||
3 | use cli::Subcommands; | 3 | use cli::Subcommands; |
4 | use config::Config; | 4 | use config::Config; |
5 | use error::{Error, Result}; | 5 | use error::{Error, Result}; |
6 | use notify_rust::Urgency; | ||
7 | use tracing::{debug, error, level_filters::LevelFilter}; | 6 | use tracing::{debug, error, level_filters::LevelFilter}; |
8 | use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; | 7 | use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; |
9 | 8 | ||
@@ -72,6 +71,21 @@ fn run_cli() -> Result<()> { | |||
72 | Ok(()) | 71 | Ok(()) |
73 | } | 72 | } |
74 | 73 | ||
74 | enum Urgency { | ||
75 | Normal, | ||
76 | Critical | ||
77 | } | ||
78 | |||
79 | #[cfg(feature = "notifications")] | ||
80 | impl From<Urgency> for notify_rust::Urgency { | ||
81 | fn from(value: Urgency) -> Self { | ||
82 | match value { | ||
83 | Urgency::Normal => Self::Normal, | ||
84 | Urgency::Critical => Self::Critical, | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | |||
75 | fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()> { | 89 | fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()> { |
76 | #[cfg(feature = "notifications")] | 90 | #[cfg(feature = "notifications")] |
77 | { | 91 | { |
@@ -86,7 +100,7 @@ fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()> | |||
86 | .body(body) | 100 | .body(body) |
87 | .icon(&icon.to_string_lossy()) | 101 | .icon(&icon.to_string_lossy()) |
88 | .timeout(0) | 102 | .timeout(0) |
89 | .urgency(urgency) | 103 | .urgency(urgency.into()) |
90 | .show()?; | 104 | .show()?; |
91 | } | 105 | } |
92 | Ok(()) | 106 | Ok(()) |