use std::process::Command;
struct SendCommand<'a> {
app_name: & 'a str,
icon: & 'a str,
urgency: & 'a str,
body: & 'a str,
action: & 'a str,
category: & 'a str,
timeout: i32,
}
impl <'a>SendCommand<'a> {
fn new() -> SendCommand<'a> {
SendCommand { app_name: "", icon: "",
urgency: "", body: "" ,action: "",
category: "", timeout: 0,}
}
fn send_notify_command(app_name: & 'a str, icon: & 'a str,
urgency: & 'a str, body: & 'a str, action: & 'a str,
category: & 'a str, timeout: i32, ) -> SendCommand<'a>
{
let command = "notify-send";
let mut args = Vec::new();
let debug_instance = Debug::new();
if !action.is_empty() && !category.is_empty() {
args.push(format!("--action={}", action));
args.push(format!("--category={}", category));
}
args.push("--app-name=".to_owned() + app_name);
args.push("--icon=".to_owned() + icon);
args.push("--urgency=".to_owned() + urgency);
args.push("--expire-time=".to_owned() + &timeout.to_string());
args.push(app_name.to_owned());
args.push(body.to_owned());
debug_instance.print_msg_arg(&args);
Command::new(command).
args(&args).
output().
expect("Error: Failed to execute command");
SendCommand{ app_name, icon, urgency, body,
action, category, timeout,}
}
}