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?

  • 2
    Is xwd -root | convert - /tmp/image.jpg what you are looking for?
    – jippie
    Dec 8, 2012 at 21:31
  • 3
    @jippie: Perhaps. Problem is that as windows are unmapped there is nothing for xwd to dump - resulting in black image. (Try that command from i.e. tty1 xwd -display :0 -root | convert xwd:- /tmp/0.png)
    – Runium
    Dec 8, 2012 at 21:38
  • unsure what you mean by 'unmapped'
    – jippie
    Dec 8, 2012 at 21:38
  • 4
    @jippie: They do not reside in memory. As I understand it: When you are on your workspace - it is active - the pixels are mapped in memory for the GPU to process and render on screen. When workspace is switched or exited (I.e by Ctrl-Alt-F1) these maps are unmapped (to free up resources) - thus there is nothing in the "display buffer" - and gives a black image.
    – Runium
    Dec 8, 2012 at 21:45
  • I see what you mean, thnx for the explanation. Don't know the answer in this case though.
    – jippie
    Dec 8, 2012 at 21:48

1 Answer 1


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.

  • Thank you for a good post. I'm looking into it. One of my major issues is that I am an old windows'er and having some problems grasping how everything is knitted together. X server, X window manager, access and composing. But getting there.
    – Runium
    Dec 14, 2012 at 19:24
  • @Sukminder Do you have difficult setting this up or need more instruction regarding this?
    – John Siu
    Dec 17, 2012 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.