Skip to content

feat: add -O to print focused output geometry immediately#183

Open
mbroemme wants to merge 1 commit intoemersion:masterfrom
mbroemme:2025-print-focused-output-geometry-immediately
Open

feat: add -O to print focused output geometry immediately#183
mbroemme wants to merge 1 commit intoemersion:masterfrom
mbroemme:2025-print-focused-output-geometry-immediately

Conversation

@mbroemme
Copy link

Description

Take a screenshot with grim using slurp of the currently focused display with the Print key. Press Print once to grab a screenshot of the monitor your mouse is currently on (the focused output), without selecting a region or clicking.

Why

On multi-monitor setups, "full-screen screenshot" often captures all outputs (huge image) or the wrong monitor. With slurp -O, the screenshot is always of the display you’re actively using.

Example:

Bind Print to:

sh -c 'grim -g "$(slurp -O)" ~/Pictures/Screenshots/$(date +%F_%H-%M-%S).png'

A PNG file is created containing exactly the focused output (its x/y origin and width/height), with no interactive selection step.

Implementation

Add a new -O option that queries the output currently containing the pointer and prints its box using the existing format string machinery, then exits without entering region selection. Reject -O when combined with -p or -r to avoid ambiguous behavior. This enables grabbing the active display dimensions instantly (e.g. for scripts) without requiring a click/drag.

Add a new -O option that queries the output currently containing the
pointer and prints its box using the existing format string machinery,
then exits without entering region selection.

Reject -O when combined with -p or -r to avoid ambiguous behavior.

This enables grabbing the active display dimensions instantly (e.g. for
scripts) without requiring a click/drag.
@mbroemme mbroemme force-pushed the 2025-print-focused-output-geometry-immediately branch from 22dc509 to cfae750 Compare December 12, 2025 12:14
@emersion
Copy link
Owner

emersion commented Dec 12, 2025

I don't think showing a layer surface and then immediately closing it is a good way to get the focused output.

I think this should be handled on the capture side instead. See e.g. https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/issues/116

@mbroemme
Copy link
Author

mbroemme commented Dec 12, 2025

Which basically means to replace wlr-screencopy with ext-image-copy-capture in grim, correct?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants