Expand description
rxscreen
is designed to be a simple, easy to use library around various functionality of the
x11 server and corresponding extensions.
Implemented features:
- X11
- Xrandr (via the
xrandr
feature) - MIT-SHM (via the
shm
feature)
§Examples
§Capture a screenshot of the entire X11 display
if let Ok(display) = Display::new(":0.0") {
let capture = display.capture()
.unwrap();
// `capture` is now an `Image` containing Bgr8 data of the image.
// You can now save it to a file, or do whatever you want with it.
}
§Capture a screenshot of a specific monitor (requires the “xrandr” feature)
#[cfg(feature = "xrandr")]
#[cfg(feature = "xrandr")]
if let Ok(display) = Display::new(":0.0") {
if let Some(monitor) = display.monitors()
.iter()
.find(|monitor| monitor.primary()) {
let capture = display.capture_area(
(monitor.x as u32, monitor.y as u32),
(monitor.width as u32, monitor.height as u32)
).unwrap();
// `capture` is now an `Image` containing the screenshot of the primary monitor as Bgr8 data.
// You can now save it to a file, or do whatever you want with it.
}
}
Re-exports§
Modules§
- Exposes the X11
xrandr
extension. - Exposes the X11
MIT-SHM
extension.