Compare commits

...

2 commits

Author SHA1 Message Date
Yash Karandikar 997ea896d4 Make it work on macos maybe?
missing can you test this for me
2022-05-11 11:30:09 -05:00
Yash Karandikar 4439e7cb47 Make backend 2022-05-11 11:28:01 -05:00
4 changed files with 37 additions and 7 deletions

12
.cargo/config.toml Normal file
View file

@ -0,0 +1,12 @@
[target.x86_64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]
[target.aarch64-apple-darwin]
rustflags = [
"-C", "link-arg=-undefined",
"-C", "link-arg=dynamic_lookup",
]

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
/target
/Cargo.lock
/venv

View file

@ -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"] }

View file

@ -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(())
}