
maim: Screenshot utility
maim: Screenshot utility
maim is a lightweight command-line tool for taking screenshots. Below are practical, example-first explanations to get you capturing with confidence.
Quick start: capture the whole screen
- Capture the full screen and save to a file:
maim /path/to/screenshot.png
- Tip: if you omit the path, maim will print a file path to stdout and may require redirection depending on your setup.
Capture a selected region
- Use the select mode to draw a region and save it to a file:
maim -s /path/to/screenshot.png
- If you want to preview or adjust the selection before saving, combine with your editor or viewer as needed.
Copy region to clipboard (requires xclip)
- Capture a selected region and pipe it to the clipboard:
maim -s | xclip -selection clipboard -t image/png
- Explanation:
- -s or —select enables region selection.
- xclip handles clipboard interaction; the -t image/png sets the MIME type.
Capture the current active window (requires xdotool)
- Grab the active window and save to a file:
maim -i $(xdotool getactivewindow) /path/to/screenshot.png
- This relies on xdotool to determine the currently focused window.
Common variants and tips
- If you want to capture the active window and then copy to clipboard:
maim -i $(xdotool getactivewindow) - | xclip -selection clipboard -t image/png
- To save to a temporary file, then open it with a viewer, you can chain commands:
maim /tmp/screenshot.png && xdg-open /tmp/screenshot.png
Common pitfalls
- Missing dependencies: maim can rely on xclip and xdotool for extended features. If a command fails due to missing tools, install them (e.g., sudo apt install xclip xdotool) and retry.
- Path permissions: ensure the destination path is writable. Use a directory like ~/Pictures or /tmp when testing.
- Clipboard nuances: clipboard behavior varies across desktop environments. Some setups require the clipboard selection to be X11-based; verify your environment supports xclip integration.
- Region selection insanity: if -s hangs or behaves oddly, ensure your terminal is in a graphical session and you’re not in a Wayland-only session that lacks xdotool functionality.
Troubleshooting quick checks
- Verify maim is installed:
maim --version
- Basic screenshot to a file:
maim ~/Pictures/screenshot.png
- If you need to check dependencies, verify xclip and xdotool are installed:
dpkg -s xclip xdotool >/dev/null 2>&1 && echo 'dependencies present' || echo 'install xclip and xdotool'
Summary
maim provides simple, script-friendly screenshot capabilities without heavy GUI tooling. Start with a full-screen capture, progress to region or window captures, and integrate with your clipboard workflow as needed. As with any command-line tool, test paths and dependencies in your environment to avoid surprises.