From 5f23d5506698081722eef6e34f11c7fb24e0b212 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 25 Sep 2024 15:22:14 +0200 Subject: fix no notifications --- src/backup.rs | 6 +++--- src/main.rs | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'src') 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::{ config::Config, error::{Error, Result}, packages::PackageList, - pathinfo::PathInfo, send_notification, + pathinfo::PathInfo, send_notification, Urgency, }; pub type Id = String; @@ -62,7 +62,7 @@ impl Backup { path.save(&backup_root)?; } - send_notification("Backup created" , "", notify_rust::Urgency::Normal)?; + send_notification("Backup created" , "", Urgency::Normal)?; Ok(()) } @@ -126,7 +126,7 @@ impl Backup { path.restore(config, &backup_root)?; } - send_notification("Backup restored" , "", notify_rust::Urgency::Normal)?; + send_notification("Backup restored" , "", Urgency::Normal)?; Ok(()) } 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; use cli::Subcommands; use config::Config; use error::{Error, Result}; -use notify_rust::Urgency; use tracing::{debug, error, level_filters::LevelFilter}; use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter}; @@ -72,6 +71,21 @@ fn run_cli() -> Result<()> { Ok(()) } +enum Urgency { + Normal, + Critical +} + +#[cfg(feature = "notifications")] +impl From for notify_rust::Urgency { + fn from(value: Urgency) -> Self { + match value { + Urgency::Normal => Self::Normal, + Urgency::Critical => Self::Critical, + } + } +} + fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()> { #[cfg(feature = "notifications")] { @@ -86,7 +100,7 @@ fn send_notification(summary: &str, body: &str, urgency: Urgency) -> Result<()> .body(body) .icon(&icon.to_string_lossy()) .timeout(0) - .urgency(urgency) + .urgency(urgency.into()) .show()?; } Ok(()) -- cgit v1.2.3