LinuxCommandLibrary

grim

Take screenshots of your desktop

TLDR

Screenshot all outputs

$ grim
copy

Screenshot a specific output
$ grim -o [path/to/output_file]
copy

Screenshot a specific region
$ grim -g "[x_position],[y_position] [width]x[height]"
copy

Select a specific region and screenshot it, (using slurp)
$ grim -g "[$(slurp)]"
copy

Use a custom filename
$ grim "[path/to/file.png]"
copy

Screenshot and copy to clipboard
$ grim - | [clipboard_manager]
copy

SYNOPSIS

grim [options] [filename]

PARAMETERS

-g, --geometry[=GEOMETRY]
    Capture region as <x>,<y> <width>x<height>. Omits to invoke slurp(1) for selection.

-t, --type=png|jpeg
    Set output format. Default: png.

-q, --quality=NUM
    JPEG quality (1-100). Default: 90.

-o, --output=OUTPUT
    Output to file or - for stdout.

-l, --log-level=LEVEL
    Log level: error, warning, info, debug. Default: error.

-h, --help
    Show help and exit.

--version
    Show version and exit.

DESCRIPTION

Grim is a lightweight, command-line screenshot utility designed for Wayland compositors based on wlroots, such as Sway and River. It captures screenshots of the entire screen, specific outputs, or user-selected regions, supporting PNG and JPEG formats. Grim integrates seamlessly with tools like slurp for interactive region selection and swappy for annotation.

Key features include geometry-based cropping, customizable JPEG quality, logging levels, and output to files or stdout for piping into image processors. It leverages the wlroots screenshot protocol (wlr-screencopy) for efficient, permission-aware captures without X11 dependencies. Ideal for tiling window manager users seeking a minimal, scriptable alternative to GUI tools like gnome-screenshot.

Usage is straightforward: run grim filename.png for full-screen PNGs or combine with options for advanced control. Grim ensures high performance and respects compositor security, making it a staple in modern Wayland workflows.

CAVEATS

Requires wlroots-based compositor with wlr-screencopy protocol. Fails silently on unsupported sessions. Region capture needs slurp installed if geometry omitted. No multi-monitor capture without scripting.

EXAMPLES

grim screenshot.png
grim -g "$(slurp)" region.png
grim -t jpeg -q 95 -o - | wl-copy
swaymsg output '*' transform normal; grim -o output.png

PIPING

Output to stdout enables chaining: grim - | jq -s -r '.[0]' for JSON metadata or image viewers.

HISTORY

Developed by Simon Ser (emersion) in 2019 as part of Sway ecosystem. First release coincided with wlroots screenshot protocol. Actively maintained, integrated into Arch, Fedora, NixOS packages.

SEE ALSO

slurp(1), swappy(1), sway(1), grimshot(1)

Copied to clipboard