aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-11-13 01:06:09 +0100
committerGustav Sörnäs <gustav@sornas.net>2020-11-13 01:06:09 +0100
commit447cdfa8d8feae4aaf1892546318a6ef4fc8ad72 (patch)
tree095e98504413b731feeb75eb1e92a020380b7653 /mumd/src
parent1b3bcebc895bfa4b6f65697fafc31d482c74b2de (diff)
parent0ae73c2522fde0307c96cfb92aca49e2176f277f (diff)
downloadmum-447cdfa8d8feae4aaf1892546318a6ef4fc8ad72.tar.gz
Merge branch 'cfg-libnotify' into 'main'
Add feature libnotify to mumd Closes #66 See merge request gustav/mum!30
Diffstat (limited to 'mumd/src')
-rw-r--r--mumd/src/notify.rs17
1 files changed, 11 insertions, 6 deletions
diff --git a/mumd/src/notify.rs b/mumd/src/notify.rs
index 82ec6b6..0739c58 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<bool> {
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(_: String) -> Option<bool> {
+ None
+}