From bd01bda3ad20760800b3b2338ff14f647a38b949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Fri, 6 Nov 2020 15:21:54 +0100 Subject: add feature libnotify to mumd --- mumd/src/notify.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'mumd/src') diff --git a/mumd/src/notify.rs b/mumd/src/notify.rs index 82ec6b6..7d08714 100644 --- a/mumd/src/notify.rs +++ b/mumd/src/notify.rs @@ -1,15 +1,20 @@ -use log::*; - pub fn init() { + #[cfg(feature = "libnotify")] libnotify::init("mumd").unwrap(); } -pub fn send(msg: String) -> bool { +#[cfg(feature = "libnotify")] +pub fn send(msg: String) -> Option { match libnotify::Notification::new("mumd", Some(msg.as_str()), None).show() { - Ok(_) => true, + Ok(_) => Some(true), Err(_) => { - debug!("Unable to send notification"); - false + log::debug!("Unable to send notification"); + Some(false) } } } + +#[cfg(not(feature = "libnotify"))] +pub fn send(_msg: String) -> Option { + None +} -- cgit v1.2.1