slurp
Capture a screen region to an image
TLDR
Select a region and print it to stdout
Select a region and print it to stdout, while displaying the dimensions of the selection
Select a single point instead of a region
Select an output and print its name
Select a specific region and take a borderless screenshot of it, using grim
Select a specific region and take a borderless video of it, using wf-recorder
SYNOPSIS
slurp [-h] [-d] [-o] [-f format] [-b color] [-c color] [-s color] [-w width]
PARAMETERS
-h
Displays a help message and exits.
-d
Prints the current geometry (x,y,w,h) of the currently focused output (monitor) to stdout and exits, without interactive selection. Useful for obtaining full screen dimensions.
-o
Restricts the interactive selection to a single output (monitor). If the selection starts on one screen, it cannot extend to another.
-f
Specifies the output format string for the selected region's geometry. Supported placeholders include %x (x-coordinate), %y (y-coordinate), %w (width), and %h (height). The default format is %x,%y,%w,%h.
-b
Sets the background color for the unselected area of the screen during interactive selection. Colors are typically specified in hexadecimal RRGGBBAA format (e.g., 00000080 for semi-transparent black).
-c
Sets the color of the selection outline or border. Similar to -b, colors are specified in hexadecimal RRGGBBAA format (e.g., FFFFFF for white).
-s
Sets the color of the active selection area while dragging. This color is applied to the region being interactively defined. Uses hexadecimal RRGGBBAA format.
-w
Sets the width of the selection outline in pixels. For example, -w 2 would create a 2-pixel wide border.
DESCRIPTION
slurp is a lightweight command-line utility designed to graphically select a rectangular region on a Wayland compositor. It outputs the coordinates (x, y, width, height) of the selected area to standard output, typically in the format x,y,w,h. This makes it an indispensable tool for scripting, especially when combined with Wayland screenshot utilities like grim to capture specific parts of the display. Users interactively define an area using a mouse or other pointing device, providing a simple yet powerful method for defining screen regions for various tasks. Beyond interactive selection, slurp can also print the geometry of the currently focused output, making it versatile for both dynamic user input and static screen information retrieval.
CAVEATS
Wayland-only: slurp is designed exclusively for Wayland compositors and will not function in X11 environments.
Interactive Requirement: For its primary function of region selection, slurp requires active user interaction via a pointing device (mouse), unless the -d option is used.
COMMON USAGE WITH GRIM
One of the most frequent uses of slurp is to pipe its output directly into the grim screenshot utility. The command grim -g "$(slurp)" allows users to interactively select a screen region, and then grim captures only that specific area. This combination is a powerful and flexible way to take targeted screenshots on Wayland.
COLOR FORMAT
Colors for options like -b, -c, and -s should be provided in hexadecimal RRGGBBAA format, where RR, GG, BB represent the red, green, and blue components (00-FF), and AA represents the alpha (transparency) component (00-FF). For example, FF0000FF is opaque red, and 00000080 is semi-transparent black.
HISTORY
slurp emerged as part of the Wayland ecosystem, specifically to complement screenshot utilities like grim. With the transition from X11 to Wayland, new tools were needed to replicate functionalities such as interactive screen region selection, which were previously handled by X-specific utilities. slurp fills this void, providing a dedicated, lightweight solution that integrates seamlessly with Wayland compositors adhering to the wlroots protocol. Its development reflects the community's effort to build a complete and robust toolset for the modern Linux desktop environment.