aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/notify.rs
blob: ee387ccf9cd5de3263e085e1207bd8b5b87b6ac7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
pub fn init() {
    #[cfg(feature = "notifications")]
    libnotify::init("mumd").unwrap();
}

#[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(_) => {
            log::debug!("Unable to send notification");
            Some(false)
        }
    }
}

#[cfg(not(feature = "notifications"))]
pub fn send(_: String) -> Option<bool> {
    None
}