15

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?

Runium
  • 28,133
  • 5
  • 50
  • 71
  • 2
    Is `xwd -root | convert - /tmp/image.jpg` what you are looking for? – jippie Dec 08 '12 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 08 '12 at 21:38
  • unsure what you mean by 'unmapped' – jippie Dec 08 '12 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 08 '12 at 21:45
  • I see what you mean, thnx for the explanation. Don't know the answer in this case though. – jippie Dec 08 '12 at 21:48
  • OK. Thanks for a good try :). At least I have found some other nice things in this endeavour. As `sudo cat /dev/vcs1` or the more friendly `sudo setterm -dump 1 -file tty1.dump` - tho that is completely off the mark :P – Runium Dec 08 '12 at 21:56

1 Answers1

7

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.

John Siu
  • 4,695
  • 2
  • 25
  • 22
  • 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 '12 at 19:24
  • @Sukminder Do you have difficult setting this up or need more instruction regarding this? – John Siu Dec 17 '12 at 15:44