Nov 16, 6:54pm

On GNOME Wayland (Debian 13 ships GNOME 48) no process can read another window's pixels directly; capture is brokered by GNOME Shell / the portals. So there are two realistic routes:

1. Simplest: focus the window, then capture the focused window

text
sudo apt install gnome-screenshot    # 41.0-3 is in trixie
gnome-screenshot -w -f shot.png      # captures the currently focused window

gnome-screenshot is allowlisted by GNOME Shell, so -w works on Wayland, unlike grim/slurp/ImageMagick which don't work on GNOME's compositor (Debian package, GNOME Wayland screenshot gist).

Caveat: -w grabs whatever window has focus, and running it from a terminal makes the terminal the focused window. Two workarounds:

  • Run it with a small delay and click the target window first: sleep 3 && gnome-screenshot -w -f shot.png
  • Or bind the command to a custom shortcut (Settings → Keyboard → Custom Shortcuts), so the target window keeps focus when you trigger it.

For a one-off, the built-in tool also does this interactively: PrtScr → click the window mode icon → click the window.

2. Fully scripted capture of a specific (not focused) window

GNOME Wayland has no scriptable per-window screenshot API (the legacy portal Screenshot method is whole-screen only and re-prompts). The supported route is the ScreenCast portal with PipeWire: you do a one-time interactive grant where you pick the window, a restore_token is saved, and from then on a script can grab frames of that window unattended (wayland-screenshot README). The wayland-screenshot tool implements exactly this (cast enroll --window once, then snap to get a PNG). Writing it by hand means a D-Bus ScreenCast session + a PipeWire frame grabber, which is why a ready-made wrapper is the pragmatic choice.

For anything beyond occasional use, route 2 is the only reliable "given window by command" option; route 1 is fine if clicking/focusing the window first is acceptable.

Nov 16, 6:54pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more