#x11 #screenshot #display #xrandr #mit-shm


A wrapper around libx11 to capture screenshots and save them

6 releases

0.1.6 Feb 13, 2023
0.1.5 Nov 16, 2022
0.1.3 Mar 4, 2021

#227 in Unix APIs

24 downloads per month

MIT license



A simple wrapper over libx11 to take screenshots.


  • libx11
  • libxext (with the shm feature)
  • libxrandr (with the xrandr feature)


  • save (save screenshots directly to file)
  • MIT-SHM (use the MIT-SHM extension to rapidly take screenshots, used for screenrecording and similar)
  • Xrandr (use Xrandr to query monitors connected to the X11 server)

Planned features

  • Graphics, to allow creating own displays and drawing on them.
  • Extend Xrandr support to change display configuration

Similar projects


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)


Capture a screenshot of the entire X11 display

if let Ok(display) = Display::new(":0.0") {
   let capture = display.capture()
   // `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()
                             .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)
      // `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.


~13K SLoC