diff options
-rw-r--r-- | src/backup.rs | 6 | ||||
-rw-r--r-- | src/main.rs | 18 |
2 files changed, 19 insertions, 5 deletions
diff --git a/src/backup.rs b/src/backup.rs index b468917..c0621fc 100644 --- a/src/backup.rs +++ b/src/backup.rs | |||
@@ -13,7 +13,7 @@ use crate::{ | |||
13 | config::Config, | 13 | config::Config, |
14 | error::{Error, Result}, | 14 | error::{Error, Result}, |
15 | packages::PackageList, | 15 | packages::PackageList, |
16 | pathinfo::PathInfo, send_notification, | 16 | pathinfo::PathInfo, send_notification, Urgency, |
17 | }; | 17 | }; |
18 | 18 | ||
19 | pub type Id = String; | 19 | pub type Id = String; |
@@ -62,7 +62,7 @@ impl Backup { | |||
62 | path.save(&backup_root)?; | 62 | path.save(&backup_root)?; |
63 | } | 63 | } |
64 | 64 | ||
65 | send_notification("Backup created" , "", notify_rust::Urgency::Normal)?; | 65 | send_notification("Backup created" , "", Urgency::Normal)?; |
66 | 66 | ||
67 | Ok(()) | 67 | Ok(()) |
68 | } | 68 | } |
@@ -126,7 +126,7 @@ impl Backup { | |||
126 | path.restore(config, &backup_root)?; | 126 | path.restore(config, &backup_root)?; |
127 | } | 127 | } |
128 | 128 | ||
129 | send_notification("Backup restored" , "", notify_rust::Urgency::Normal)?; | 129 | send_notification("Backup restored" , "", Urgency::Normal)?; |
130 | 130 | ||
131 | Ok(()) | 131 | Ok(()) |
132 | } | 132 | } |
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(()) |