Screenshot of X from tty

screenshotttyx11

Using Xvfb I can launch an application and take a screenshot.

What I'm wondering about is how to capture from an existing (dormant) X session.

Say from tty or over ssh.

From what I understand windows are unmapped and does not exist to preserve resources. Are there some tool that can map existing windows, workspaces etc in a virtual windowmanager and take a snap?

Or can one perhaps use libx11 and create a snap by using XShmCreateImage or similar?

Best Answer

We can "turn on" the X tty manually from command line, without ctrl-alt-F(x).

If X is on tty 7, and you login a text terminal

chvt 7 ; DISPLAY=0.0 xwd -root > screendump.xwd ; chvt 1

However, xhost + localhost must be issue within the xsession, else xwd cannot connect to x server.

This allow you to do it from ssh session.

PS: In theory, with MTD, it should be possible to do screen capture from video card memory. Thus without first "waking" the X session.

Related Question