grim-rs 0.2.0

Rust implementation of grim screenshot utility for Wayland and Windows
Documentation

grim-rs

Crates.io Version

[!IMPORTANT] CHANGELOG · API · MIGRATION · Examples

if you like this project, then the best way to express gratitude is to give it a star ⭐, it doesn't cost you anything, but I understand that I'm moving the project in the right direction.


Rust implementation of grim screenshot utility for Wayland compositors and Windows (DXGI Desktop Duplication).

Features

  • Pure Rust implementation
  • Cross-platform: same API on Linux (Wayland) and Windows (DXGI)
  • Native capture via ext-image-copy-capture-v1, zwlr_screencopy_manager_v1, or DXGI
  • Multi-output capture and compositing
  • Adaptive image scaling (Nearest / Triangle / CatmullRom / Lanczos3)
  • PNG / JPEG output
  • Cursor overlay support
  • No external runtime screenshot tools required

Usage

As a Library

cargo add grim-rs

[dependencies]

grim-rs = "0.2"

MSRV: Rust 1.68+

use grim_rs::Grim;

fn main() -> grim_rs::Result<()> {
    let mut grim = Grim::new()?;
    let result = grim.capture_all()?;
    grim.save_png(result.data(), result.width(), result.height(), "screenshot.png")?;
    Ok(())
}

Command Line

# Quick start

cargo run --bin grim-rs


# Capture specific region

cargo run --bin grim-rs -- -g "100,100 800x600" region.png


# Install and run direct binary

cargo install grim-rs

grim-rs -o DP-1 -c monitor.png

Full CLI reference: doc/cli.md

Architecture

grim-rs architecture

Processing Pipeline

grim-rs pipeline

Supported Platforms

Linux (Wayland): Hyprland, Sway, River, Wayfire, Niri, any wlroots-based compositor

Windows: Windows 8+ with DXGI Desktop Duplication support

Limitations

  • Linux: Requires compositor with ext-image-copy-capture-v1 or zwlr_screencopy_manager_v1
  • Windows: Grim::new_ext() and Grim::new_wlr() return Error::UnsupportedProtocol (Wayland-only); protected content (DRM) cannot be captured

Building

cargo build --release

Contributing

See CONTRIBUTING.md.

License

MIT License - see LICENSE file for details.