use std::io::Write; use std::process::{exit, Command, Stdio}; use web_view::*; fn main() { #[cfg(debug_assertions)] let js = include_str!("../../elmoji/js/main.js"); #[cfg(not(debug_assertions))] let js = include_str!("../../elmoji/js/main.min.js"); let html_content = include_str!("../../elmoji/index.html").replace( "", &format!("", js), ); web_view::builder() .title("Elmojinput") .content(Content::Html(html_content)) .size(512, 512) .resizable(false) .debug(true) .user_data(()) .invoke_handler(|_webview, arg| { let mut child = Command::new("xclip") .arg("-selection") .arg("clipboard") .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn() .unwrap(); let stdin = child.stdin.as_mut().unwrap(); stdin.write_all(arg.as_bytes()).unwrap(); exit(0); }) .run() .unwrap(); }