use std::path::Path;
use super::ScreenshotError;
pub(crate) fn capture_screencapture(window_id: u32, path: &Path) -> Result<(), ScreenshotError> {
use std::process::Command;
let status = Command::new("screencapture")
.arg("-x")
.arg("-l")
.arg(window_id.to_string())
.arg(path)
.status()
.map_err(|err| ScreenshotError::CaptureFailed { message: format!("spawn screencapture: {err}") })?;
if !status.success() {
return Err(ScreenshotError::CaptureFailed { message: format!("screencapture exited with {status}") });
}
Ok(())
}