LinuxCommandLibrary

maim

Send and receive email from the command line

TLDR

Capture a screenshot and save it to the given path

$ maim [path/to/screenshot.png]
copy

Capture a screenshot of the selected region
$ maim [[-s|--select]] [path/to/screenshot.png]
copy

Capture a screenshot of the selected region and save it in the clipboard (requires xclip)
$ maim [[-s|--select]] | xclip [[-se|-selection]] [[c|clipboard]] [[-t|-target]] image/png
copy

Capture a screenshot of the current active window (requires xdotool)
$ maim [[-i|--window]] $(xdotool getactivewindow) [path/to/screenshot.png]
copy

SYNOPSIS

maim [OPTIONS] [FILE]

PARAMETERS

-s, --select
    Select a region of the screen or a window with slop or slurp.

-i ID, --window ID
    Capture a specific window by its X window ID.

-c, --active
    Capture the currently active window.

-d N, --delay N
    Delay screenshot by N seconds.

-m N, --monitor N
    Capture a specific monitor by number.

-u, --no-cursor
    Do not include the mouse cursor in the screenshot.

-k, --keep-cursor
    Always include the mouse cursor (default behavior if no -u). For grim captures, this is default.

-f FORMAT, --format FORMAT
    Specify the output image format (e.g., png, jpeg, webp). Defaults to png.

-q N, --quality N
    Set JPEG/WEBP compression quality (0-100). Ignored for PNG.

-P, --grim
    Use grim for Wayland screenshots. Requires grim and slurp.

-N, --no-grim-notify
    Do not notify if grim is not found when -P is used.

-o, --stdout
    Output image data to standard output.

-B COLOR, --background COLOR
    Set background color for transparent areas (e.g., "#000000"). Only affects PNG output with alpha channel.

-t N, --threshold N
    Set slop click detection threshold (in pixels). maim passes this to slop.

-h, --help
    Display help information and exit.

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

DESCRIPTION

maim (make image) is a simple, yet powerful, command-line utility designed for taking screenshots on Linux. It's often favored by users of tiling window managers due to its lightweight nature and ability to integrate seamlessly with other tools. Unlike some more feature-rich GUI screenshot tools, maim focuses on performing its core task efficiently and then allowing external programs to handle selection, clipboard management, or image manipulation.

It supports capturing the entire screen, a specific window, or a user-selected region. For region selection on X, it typically leverages slop (select operation), allowing for pixel-perfect selections. On Wayland, maim can utilize grim for screen capture and slurp for region selection, making it a versatile choice across different display servers. Its output can be saved directly to a file, piped to standard output, or sent to the clipboard via tools like xclip (X) or wl-clipboard (Wayland).

maim is known for its speed and minimal dependencies, making it an excellent choice for scripting custom screenshot workflows.

CAVEATS

maim heavily relies on external utilities for certain functionalities:
Region Selection: On X, it requires slop to enable interactive region selection (-s). On Wayland, it requires slurp.
Wayland Support: Native Wayland screenshots require the grim utility (-P option). Without it, maim will primarily function on X display servers.
Clipboard Integration: To copy screenshots directly to the clipboard, you'll need xclip (for X) or wl-clipboard (for Wayland).
Dependencies: Ensure necessary Xorg development headers and libraries (e.g., libXrandr, libXfixes) are installed for compilation or proper execution on X.

<I>USAGE EXAMPLES</I>

Full screen to file:
`maim ~/screenshot.png`


Select region to file:
`maim -s ~/selection.png`


Active window to clipboard (X):
`maim -i $(xdotool getactivewindow) | xclip -selection clipboard -t image/png`


Select region to clipboard (Wayland with grim):
`maim -P -s | wl-copy`


Full screen with a delay:
`maim -d 3 ~/delayed_screenshot.png`


Output as JPEG with quality:
`maim -f jpeg -q 80 ~/screenshot.jpg`

<I>INTEGRATION WITH EXTERNAL TOOLS</I>

maim's strength lies in its ability to compose with other command-line tools. For instance, slop provides the graphical selection interface, allowing you to drag a rectangle or click on a window. xclip (X) and wl-clipboard (Wayland) handle clipboard operations, making it easy to paste screenshots directly into documents or image editors. grim and slurp are the Wayland equivalents for capturing and selecting. This modular approach ensures maim remains lean while providing powerful capabilities through external dependencies.

HISTORY

The maim utility was created by Zeeshan Ali, who also developed slop, the highly customizable selection tool maim often uses. It emerged as a lightweight, flexible alternative to older screenshot tools, designed to integrate well with scripting and minimalist window managers like i3, bspwm, and AwesomeWM. Its development philosophy emphasizes single-purpose tools that can be effectively piped together, which is a common Unix paradigm. maim has gained popularity within the power-user community for its speed, minimal overhead, and ability to be easily customized through shell scripts, adapting to various workflows on both X and, more recently, Wayland display servers.

SEE ALSO

scrot(1), gnome-screenshot(1), spectacle(1), xclip(1), wl-clipboard(1), slop(1), grim(1), slurp(1)

Copied to clipboard