--- src/bin/vrec-ui.rs +++ src/bin/vrec-ui.rs @@ -1,18 +1,8 @@ -use vrec::ipc::Command; +use vrec::ipc::{Command, send_command}; use std::os::unix::net::UnixStream; use std::io::Write; use std::env; use global_hotkey::{GlobalHotKeyManager, hotkey::{HotKey, Modifiers, Code}, GlobalHotKeyEvent}; - -fn send_command(cmd: Command) -> Result<(), Box> { - let socket_path = format!("{}/vrec.sock", env::var("XDG_RUNTIME_DIR").unwrap_or_else(|_| "/tmp".to_string())); - let mut stream = UnixStream::connect(&socket_path)?; - let payload = serde_json::to_vec(&cmd)?; - let len_buf = (payload.len() as u32).to_le_bytes(); - stream.write_all(&len_buf)?; - stream.write_all(&payload)?; - Ok(()) -} fn main() -> Result<(), Box> {