LinuxCommandLibrary

slop

Select a screen region and output coordinates

TLDR

Wait for the user to make a selection and output its geometry to stdout

$ slop
copy

Double click, rather than click and drag, to draw a selection
$ slop [[-D|--nodrag]]
copy

Highlight the selection rather than outlining it
$ slop [[-l|--highlight]]
copy

Specify the output format
$ slop [[-f|--format]] [format_string]
copy

Specify the selection rectangle's color
$ slop [[-c|--color]] [red],[green],[blue],[alpha]
copy

SYNOPSIS

slop [OPTIONS]

PARAMETERS

-s, --scale
    Output coordinates scaled by this factor.

-b, --border
    Set selection border color and thickness. E.g., "red:2".

-c, --color
    Set selection box fill color.

-f, --format
    Specify output format string. E.g., "%x %y %w %h" or "%g" for WxH+X+Y.

-t, --tolerance
    Pixel tolerance for snapping to windows or outputs.

--highlight-active-outputs
    Highlight detected active outputs. (Wayland specific).

--passive
    Don't grab keyboard/pointer; useful for overlays or non-interactive use.

--pointer-color
    Set the color of the pointer.

--rects
    Read initial rectangles from a file to display.

--fill-rects
    Fill rectangles specified by --rects instead of just bordering them.

-h, --help
    Show help message and exit.

-v, --version
    Show version information and exit.

DESCRIPTION

slop is a command-line utility designed for interactively selecting a region of the screen and printing its geometry coordinates to standard output. It supports both X11 and Wayland display servers, making it a versatile tool for various desktop environments. While slop itself does not capture screenshots, it is commonly used in conjunction with other screenshot tools like grim (for Wayland) or scrot (for X11) by piping its output as the target region for capture. The output format is highly configurable, allowing users to specify the desired coordinates (x, y, width, height) and their separator. Its simplicity and composability make it an essential component for custom screenshot scripts and other graphical automation tasks requiring precise region selection.

CAVEATS

slop requires a running Wayland compositor or X server to function correctly. Its behavior and appearance might vary slightly between different compositors and X window managers due to variations in drawing and input handling. Ensure the necessary permissions and display server socket access are available. For Wayland, it relies on specific Wayland protocols (like `wlr_layer_shell`, `wlr_input_inhibitor`) which might not be supported by all compositors, although support is widespread.

COMMON USAGE

To capture a selected region using grim (Wayland):
grim -g "$(slop -f "%g")" output.png

To capture a selected region using scrot (X11):
scrot -g "$(slop -f "%g")" output.png
Note: While scrot's `-s` option provides built-in interactive selection, slop offers more control over selection appearance and output format, or for consistency across display servers.

OUTPUT FORMAT PLACEHOLDERS

The `-f` or `--format` option allows specifying a custom output string using placeholders:
%x: X coordinate of the top-left corner.
%y: Y coordinate of the top-left corner.
%w: Width of the selected region.
%h: Height of the selected region.
%g: Geometry string (e.g., "WIDTHxHEIGHT+X+Y").
%o: Output index (Wayland only).

HISTORY

slop emerged as part of the growing ecosystem of Wayland-native tools, designed to provide the functionality of X11 tools like `xwininfo -geometry` or `import` in the Wayland environment. It gained popularity particularly within the Sway community, a tiling Wayland compositor, where it integrates seamlessly with `grim` for region-based screenshots. Its development reflects the ongoing effort to build a robust and feature-rich set of utilities for the Wayland display server, mirroring the capabilities available on X11, emphasizing simplicity and composability.

SEE ALSO

grim(1), scrot(1), maim(1), slurp(1), xrandr(1), swaymsg(1)

Copied to clipboard