aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/notifications.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-03-30 11:27:10 +0200
committerGustav Sörnäs <gustav@sornas.net>2021-03-30 15:25:56 +0200
commitd8c269f66a4a5a17155bec5e2cb5ad97f3ba00fd (patch)
treed456500252f4c94db8f33775242dffb2335b8e96 /mumd/src/notifications.rs
parent0362df3a4a5d91cb2b8e530d44de327da7a18765 (diff)
downloadmum-d8c269f66a4a5a17155bec5e2cb5ad97f3ba00fd.tar.gz
rename notify -> notifications
Notify is already taken, see https://lib.rs/crates/notify.
Diffstat (limited to 'mumd/src/notifications.rs')
-rw-r--r--mumd/src/notifications.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/mumd/src/notifications.rs b/mumd/src/notifications.rs
new file mode 100644
index 0000000..e52b909
--- /dev/null
+++ b/mumd/src/notifications.rs
@@ -0,0 +1,24 @@
+use log::*;
+
+pub fn init() {
+ #[cfg(feature = "notifications")]
+ if libnotify::init("mumd").is_err() {
+ warn!("Unable to initialize notifications");
+ }
+}
+
+#[cfg(feature = "notifications")]
+pub fn send(msg: String) -> Option<bool> {
+ match libnotify::Notification::new("mumd", Some(msg.as_str()), None).show() {
+ Ok(_) => Some(true),
+ Err(_) => {
+ warn!("Unable to send notification");
+ Some(false)
+ }
+ }
+}
+
+#[cfg(not(feature = "notifications"))]
+pub fn send(_: String) -> Option<bool> {
+ None
+}