#[link(name = "CoreGraphics", kind = "framework")]
unsafe extern "C" {
fn CGPreflightScreenCaptureAccess() -> bool;
fn CGRequestScreenCaptureAccess() -> bool;
}
pub fn has_screen_capture_access() -> bool {
unsafe { CGPreflightScreenCaptureAccess() }
}
pub fn request_screen_capture_access() -> bool {
unsafe { CGRequestScreenCaptureAccess() }
}
pub const GRANT_INSTRUCTIONS: &str = "\
Screen Recording permission is NOT granted.
pixelcoords can only capture your wallpaper until it is.
To grant it:
1. Open System Settings -> Privacy & Security -> Screen & System Audio Recording
2. Enable the terminal app you run pixelcoords from (Terminal, iTerm2, Ghostty, VS Code, ...)
3. Quit and reopen that terminal app, then run `pixelcoords doctor` again
If the app is missing from the list, run `pixelcoords` once to trigger the
permission prompt, or add the terminal manually with the '+' button.";