How to take screenshots of partially/fully obscured windows in Xorg/X11
I initially posted this on my Fediverse account, and I’m now reposting it here for visibility. The all-lowercase text adds to the charm, so I’ll keep it.
…you can’t, not conventionally anyways. but there is a workaround! just start up an x session with xnest (that way you can still access the window you want to do stuff on). this will simply open a window with your new x session inside of it, and that should be enough
- install
xorg-server-xnest xwininfo imagemagick
- run
Xnest :1 -geometry 1000x1400
(substitute 1000x1400 with whatever resolution you want your new session to be. probably larger than your target window) - find the window id of the window you want to capture with
DISPLAY=:1 xwininfo -tree
- take a screenshot with
DISPLAY=:1 import -winid <window id you got in the previous command> targetfile.png
if you get “resource temporarily unavailable” try a different window id
if all goes well, you should have a new png file that contains the screenshot! if you get a buggy screenshot, move the xnest window around a bit and try again
Categories:
Comments