Make backend
This commit is contained in:
parent
59e9f1ca73
commit
4439e7cb47
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
/target
|
||||
/Cargo.lock
|
||||
/venv
|
||||
|
|
|
@ -4,5 +4,9 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
[lib]
|
||||
name = "wn_backend"
|
||||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies]
|
||||
pyo3 = { version = "0.16.4", features = ["extension-module"] }
|
||||
|
|
27
src/lib.rs
27
src/lib.rs
|
@ -1,8 +1,21 @@
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = 2 + 2;
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
use pyo3::prelude::*;
|
||||
use std::process::Command;
|
||||
|
||||
#[pyfunction]
|
||||
fn send_notification(icon_path: &str, nick: &str, text: &str) -> PyResult<()> {
|
||||
Command::new("notify-send")
|
||||
.arg("-i")
|
||||
.arg(icon_path)
|
||||
.arg(format!("{}:", nick))
|
||||
.arg(text)
|
||||
.spawn()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[pymodule]
|
||||
fn wn_backend(_py: Python, m: &PyModule) -> PyResult<()> {
|
||||
m.add_function(wrap_pyfunction!(send_notification, m)?)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue