use std::sync::Arc;
use super::*;
use notify_rust::Notification;
pub struct Desktop;
impl Module for Desktop {
async fn load(&self, state: &mut State) -> Result<(), LuaError> {
let module = state.lua.create_table()?;
module.set(
"notify",
state.lua.create_function(
|_, (summary, body, icon): (String, String, Option<String>)| {
let mut n = Notification::new();
n.summary(&summary);
n.body(&body);
n.auto_icon();
if let Some(icon) = icon {
n.icon(&icon);
}
match n.show() {
Ok(_handle) => {}
Err(e) => return Err(LuaError::external(Arc::new(e))),
}
Ok(())
},
)?,
)?;
create_module(&state.lua, "autosway.desktop", module)?;
Ok(())
}
}