The most practical starting point for desktop screenshots in Rust is XCap 0.9.8. It exposes monitor enumeration, full-screen capture, window and region-oriented APIs, and image saving. The basic program is short: list monitors, call capture_image(), then save each image. Platform support is not identical, however—especially on Linux Wayland—so select the crate and backend for the systems you actually ship on.
Capture every monitor with XCap
Add XCap to your project (the examples below target the 0.9.8 API shown in its current documentation), then use a fallible main so capture and file errors are reported instead of hidden by unwrap().
use xcap::Monitor;
fn main() -> Result<(), Box<dyn std::error::Error>> {
for (index, monitor) in Monitor::all()?.into_iter().enumerate() {
let image = monitor.capture_image()?;
image.save(format!("monitor-{index}.png"))?;
}
Ok(())
}
Run it with cargo run --release. A dual-monitor system will normally produce monitor-0.png and monitor-1.png in the process’s current directory. The returned monitor objects contain display metadata you can inspect before deciding which output to capture.
Choose the capture unit you need
All displays
Monitor::all() is the documented pattern when you need one image per display. It avoids assuming a particular monitor count or primary-display arrangement.
Recommended Free Tools
#1 Best Overall
- Spacious Design: Measuring 21.1" wide and 14.1" deep, our lap desk comfortably fits most laptops up to 15.6". Extra room for accessories ensures convenience.
- Enhanced Functionality: Packed with handy features, including a 5x9" precision tracking mouse pad and a built-in phone slot for seamless work or video calls. Plus, enjoy ergonomic support with the integrated cushioned wrist rest.
- Cool Comfort: Enjoy a stable surface with our lap desk's dual bolster cushion, designed for comfort and airflow, keeping your lap cool during extended use.
- Durable Surface: Work with confidence on our lap desk's solid surface, featuring a sleek black carbon color, ensuring optimal air circulation to prevent your laptop from overheating.
- On-the-Go Convenience: With an integrated handle and lightweight design (2.8 lbs), our lap desk is portable for travel or moving around the house, offering flexibility in any space.
One monitor
Enumerate the monitors, inspect their metadata, select the desired object, and call capture_image(). Do not identify a monitor solely by enumeration order; order can change when displays are connected, disconnected, or reconfigured.
A window or arbitrary region
XCap’s documentation also covers window and region capture. Use those APIs when a full monitor image would include unrelated applications. A region workflow should account for coordinates, scaling, and whether the rectangle crosses displays; validate the coordinates on every target desktop configuration.
Saving and processing
The examples save PNG files through the returned image type. If you need JPEG or WebP, verify the image encoder and quality controls exposed by the exact dependency version you build against; the cited examples establish PNG saving, not a universal list of encodings or quality defaults.
Project setup and production-safe error handling
- Create a binary crate with
cargo new desktop-shotand add the XCap dependency version you have selected. - Keep capture and storage in separate functions so a permission, backend, or disk failure can be reported with context.
- Return
Resultfrom command-line entry points. Replace documentation-onlyunwrap()calls with?or explicit recovery. - Use a deterministic output directory and ensure it exists before saving. Include a timestamp or job identifier if repeated captures must not overwrite one another.
- Test a clean build and a release build on each operating system and display backend you promise to support.
use std::{fs, path::PathBuf};
use xcap::Monitor;
fn capture_to(dir: &PathBuf) -> Result<usize, Box<dyn std::error::Error>> {
fs::create_dir_all(dir)?;
let mut count = 0;
for (index, monitor) in Monitor::all()?.into_iter().enumerate() {
let path = dir.join(format!("monitor-{index}.png"));
monitor.capture_image()?.save(path)?;
count += 1;
}
Ok(count)
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let count = capture_to(&PathBuf::from("shots"))?;
println!("saved {count} monitor image(s)");
Ok(())
}
Platform support, with special attention to Linux Wayland
| Environment | What the documented options establish | What you must verify |
|---|---|---|
| Windows | XCap lists Windows 8.1 and later. | Window permissions, scaling, protected surfaces, and the exact Windows versions in your deployment. |
| macOS | XCap lists macOS support. | Screen-recording privacy permission and behavior on the macOS releases you support. |
| Linux X11 | XCap lists Linux X11 support. | Runtime libraries, display access, multi-monitor geometry, and compositor behavior. |
| Linux Wayland | XCap marks screen and window capture as available but not fully supported in some special scenarios. | Your compositor, protocol availability, portal policy, prompts, and whether window capture is exposed. |
Wayland is a protocol family rather than one uniform capture API. A native screencopy protocol may be available on one compositor but not another. Portal-based capture can work across desktop environments but may display a user confirmation dialog. Treat the support matrices as starting points, not a substitute for testing the actual compositor, session type, scaling, and permission policy used by your application.
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemsRank #2
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
Alternatives when XCap is not the right fit
| Crate | Documented strengths | Important qualification |
|---|---|---|
screenshots 0.8.10 |
Screen::all(), capture(), capture_area(...), and image saving. |
Its README says “Move to XCap.” On Linux it lists native packages including libxcb, libxrandr, and dbus; Debian/Ubuntu examples name libxcb1 libxrandr2 libdbus-1-3. Treat these as requirements for that crate/version, not every screenshot library. |
miniscreenshot_desktop 0.2.0 |
A small take() API with automatic backend selection. |
Its sequence checks Wayland plus zwlr_screencopy_manager_v1, then X11, then XDG Desktop Portal. Portal capture is documented for GNOME, KDE, Flatpak, and Snap and may show a confirmation dialog. |
sss_capture 0.1.0 |
Desktop, monitor, window, region, and cursor-oriented APIs; typed errors; native Linux strategy. | It prefers native wlr-screencopy, then XDG Desktop Portal, then X11 through XWayland. The docs.rs page records a 2026-05-17 release, so check API maturity and target compatibility before standardizing on it. |
Compare candidates on capture unit, operating systems, Linux backend requirements, possible portal prompts, native dependencies, API and error design, release maturity, and license. The available documentation does not establish a speed ranking or independent reliability score.
How to capture a specific area safely
- Obtain the display or window metadata from the crate API rather than hard-coding a single desktop size.
- Convert your desired logical coordinates to the coordinate system expected by the backend, accounting for fractional or high-density scaling.
- Reject rectangles with negative width or height, and decide how to handle a rectangle that extends beyond a display.
- Capture the region and save it to a unique path.
- Test the same coordinates with the window moved between monitors and with displays arranged to the left or above the primary display.
Coordinates and scaling are common sources of “correct API, wrong pixels” bugs. Keep the coordinate conversion close to your platform-specific adapter, and log the selected display, rectangle, and scale during diagnostics.
Common failures and fixes
Monitor::all() or capture returns an error
Check that the process can access the active graphical session, that the required backend is present, and that privacy or portal permission has been granted. Log the complete error and the session type (X11, Wayland, or another environment) rather than retrying blindly.
The image is blank or incomplete
Protected windows, compositor restrictions, unsupported Wayland scenarios, and permission decisions can all produce incomplete results. Reproduce with a normal unprotected window, test the compositor’s supported protocol, and verify that the application has screen-recording access where the operating system requires it.
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Clear out junk files and repair common Windows errorsFree Scan →Rank #3
- Note: Not suitable for MacBooks released after 2023 or devices with a protruding front camera; Not applicable to full-screen or notch-style tempered glass screen protectors; Do not use on the rear camera of the phone.
- 💻 Why Do You Need a Webcam Cover Slide? — Safeguard your privacy by covering your webcam with our reliable webcam cover when not in use. Don't let anyone secretly watch you. Stay protected!
- ✅ Thin & Stylish — Enhance your laptop's functionality and aesthetics with our 0.027" ultra-thin webcam covers. Seamlessly close your laptop while adding a touch of sophistication.
- ✅ Fits Most Devices — Compatible with laptops, phones, tablets, desktops! Keep your privacy intact on Ap/ple, Mac/Book, iPh/one, iP/ad, H/P, L/novo, De/ll, Ac/er, As/us, Sa/msung devices.
- ✅ 365 Days Protection — Our upgraded 3.0 adhesive ensures a strong hold that won't damage your equipment. Experience reliable, long-term privacy protection day in and day out.
Wayland works on one machine but not another
Identify the compositor and whether zwlr_screencopy_manager_v1, native wlr-screencopy, or an XDG Desktop Portal is available. A portal may require an interactive confirmation, which is unsuitable for a completely unattended service unless the deployment policy provides another approved path.
Linux linking or startup errors
For the documented screenshots 0.8.10 path, install the listed native packages and their development/runtime equivalents appropriate to your distribution. Do not assume those package names are required by XCap or another crate; inspect that crate’s current build instructions.
Files are overwritten
Use a timestamp, UUID, or job identifier in the filename, and write to a controlled directory. If several workers capture concurrently, give each job its own path and handle rename failures.
Capture is slow
No reviewed documentation provides a benchmark, so do not promise a frame rate or latency. Measure on your target displays and compositors, then profile encoding and disk I/O separately from the capture call. Reuse buffers or reduce image dimensions only after measuring the trade-off you need.
Rank #4
- Anti-Slip Surface - Transform your laptop into a mobile workstation with the AboveTEK portable laptop lap desk. The anti-slip surface provides a strong grip for laptops up to 15.6 inches(Diagonal), while the double rubber strip on the bottom ensures a stable display or typing experience on your lap, couch, or bed.
- Retractable Mouse Pad - Retractable laptop mouse pad extends on both directions for the left/right handed with elevation along the edges for stopping mouse from falling off. The size of laptop tray is 14" X 9.7" and the size of mouse pad is 7.4" X 6.1".
- Effective Heat Shield - The effective heat shield made of sturdy and thick material protects your laptop from overheating. Prioritizes your comfort and safety, an ideal lap pad or board for working anywhere.
- EASY to Carry and Store - With an ergonomic and simplistic design, the lap desk is portable to store in a backpack. Only 15" in size, 2.2 lb of weight and with slim 0.6 inch thickness, it is ready to be easily carried around.
- Widely Applicable - The smooth platform accommodates laptops and tablets up to 15.6 inches(Diagonal), making it a versatile accessory and one of the best gifts for mom, dad, students and professionals. Perfect for use as a laptop bed tray or tablet holder anywhere at home, library, or park.
Testing checklist before shipping
- Windows 8.1 or later, supported macOS releases, Linux X11, and each Wayland compositor you claim to support.
- Single and multiple monitors, mixed resolutions, fractional scaling, and displays positioned on every side of the primary display.
- Full monitor, window, and region cases, including a window moved between monitors.
- Permission denied, portal cancellation, disconnected display, protected content, and unwritable output directory.
- Debug and release builds, repeated captures, concurrent requests, and long-running processes.
- Image dimensions, color mode, file integrity, and cleanup of partially written files after an error.
Or skip the browser setup
If what you actually need is a screenshot of a website rather than the developer’s local desktop, ScreenshotNeo provides a single HTTP request. It accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each cleanup step can be disabled. Only clean shots are billed: bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and whether it was billed. It also offers an MCP server for Claude, Cursor, and other MCP clients, with take_screenshot, get_page_info, and capture_pdf tools.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation for output formats and options. The same request in Python is:
import requests
r = requests.get(
"https://api.screenshotneo.com/v1/shot",
params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
timeout=90,
)
r.raise_for_status()
open("shot.webp", "wb").write(r.content)
And in Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`HTTP ${res.status}`);
require('fs').writeFileSync('shot.webp', Buffer.from(await res.arrayBuffer()));
ScreenshotNeo includes full-page capture with lazy images loaded, CSS-selector element capture, dark mode, device presets or custom viewports, retina scale, PDF paper and page controls, custom CSS and JavaScript, click and wait conditions, request/resource blocking, headers, cookies, user agents, authorization, timezone and geolocation, transparent backgrounds, resizing, chosen cache TTLs, signed links, asynchronous jobs with signed webhooks, bulk capture for up to 100 URLs per call, a usage API, and an OpenAPI specification. Its parameter names are compatible with those used by other screenshot APIs, which can simplify migration.
| Plan | Included shots | Price |
|---|---|---|
| Free | 1,000/month | $0, no card |
| Starter | 3,000 | $5 |
| Growth | 15,000 | $15 |
| Pro | 60,000 | $39 |
| Scale | 250,000 | $99 |
| Business | 1,000,000 | $249 |
Yearly billing gives two months free, and every feature is available on every plan. Create a free ScreenshotNeo account to get 1,000 screenshots a month without a card.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →FAQ
Does a Rust screenshot crate need a GUI event loop?
The documented XCap monitor example does not show an event loop; it enumerates monitors, captures, and saves. Window-management integrations may impose additional application requirements, so follow the chosen crate’s API for that capture mode.
Best Value
- Spacious Design: Measuring 21.1" wide and 12" deep, our lap desk comfortably fits most laptops up to 15.6". Extra room for accessories ensures convenience.
- Enhanced Functionality: Packed with handy features, including a 5x9" precision tracking mouse pad and a built-in phone slot for seamless work or video calls. Plus, enjoy laptop support with the integrated device ledge.
- Cool Comfort: Enjoy a stable surface with our lap desk's dual bolster cushion, designed for comfort and airflow, keeping your lap cool during extended use.
- Durable Surface: Work with confidence on our lap desk's solid surface, featuring a blush pink color, ensuring optimal air circulation to prevent your laptop from overheating.
- On-the-Go Convenience: With an integrated handle and lightweight design (2.14 lbs), our lap desk is portable for travel or moving around the house, offering flexibility in any space.
Can I use a portal in an unattended Linux service?
A portal flow may show a confirmation dialog. Confirm that interactive approval fits your deployment; otherwise select and test a backend permitted by the target compositor and security policy.
Is XCap guaranteed to capture every Wayland window?
No. Its status table includes a caveat that Wayland screen and window capture is not fully supported in some special scenarios. Validate the exact compositor and use case.
Frequently Asked Questions
Does a Rust screenshot crate need a GUI event loop?
The documented XCap monitor example does not show an event loop; it enumerates monitors, captures, and saves. Window-management integrations may impose additional application requirements, so follow the chosen crate’s API for that capture mode.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Can I use a portal in an unattended Linux service?
A portal flow may show a confirmation dialog. Confirm that interactive approval fits your deployment; otherwise select and test a backend permitted by the target compositor and security policy.
Is XCap guaranteed to capture every Wayland window?
No. Its status table includes a caveat that Wayland screen and window capture is not fully supported in some special scenarios. Validate the exact compositor and use case.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

