1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::process::Command;

use crate::{Cause, CausedResult, Error};

#[cfg(unix)]
fn notify_impl(title: &str, message: &str) -> CausedResult<()> {
    let mut child_process = Command::new("notify-send")
        .arg(title)
        .arg(message)
        .spawn()?;
    let exit_status = child_process.wait()?;

    if !exit_status.success() {
        Err(Error::new(
            Cause::InvalidState,
            "Error executing notify-send",
        ))
    } else {
        Ok(())
    }
}

#[cfg(macos)]
fn notify_impl(title: &str, message: &str) -> CausedResult<()> {
    unimplemented!();
}

pub fn send(title: &str, message: &str) -> CausedResult<()> {
    notify_impl(title, message)
}