aboutsummaryrefslogtreecommitdiffstats
path: root/mumd
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-11-06 15:21:54 +0100
committerGustav Sörnäs <gustav@sornas.net>2020-11-06 15:21:54 +0100
commitbd01bda3ad20760800b3b2338ff14f647a38b949 (patch)
tree00b1f37634a3b433df43333ec47fcc95dd6bdbb1 /mumd
parentd6496cb0f6abba855b04338fa8bc5aaa89487c29 (diff)
downloadmum-bd01bda3ad20760800b3b2338ff14f647a38b949.tar.gz
add feature libnotify to mumd
Diffstat (limited to 'mumd')
-rw-r--r--mumd/Cargo.toml6
-rw-r--r--mumd/src/notify.rs17
2 files changed, 16 insertions, 7 deletions
diff --git a/mumd/Cargo.toml b/mumd/Cargo.toml
index 350d81e..3dfc82c 100644
--- a/mumd/Cargo.toml
+++ b/mumd/Cargo.toml
@@ -8,6 +8,9 @@ edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+[features]
+default = ["libnotify"]
+
[dependencies]
mumlib = { path = "../mumlib" }
@@ -17,7 +20,6 @@ cpal = { git = "https://github.com/RustAudio/cpal" }
futures = "0.3"
futures-util = "0.3"
ipc-channel = "0.14"
-libnotify = "1.0"
log = "0.4"
mumble-protocol = "0.3"
native-tls = "0.2"
@@ -28,5 +30,7 @@ tokio = { version = "0.2", features = ["full"] }
tokio-tls = "0.3"
tokio-util = { version = "0.3", features = ["codec", "udp"] }
+libnotify = { version = "1.0", optional = true }
+
#compressor = "0.3"
#daemonize = "0.4"
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<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(_msg: String) -> Option<bool> {
+ None
+}