Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
1  
Is xwd -root | convert - /tmp/image.jpg what you are looking for? –  jippie Dec 8 '12 at 21:31
2  
@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) –  Sukminder Dec 8 '12 at 21:38
    
unsure what you mean by 'unmapped' –  jippie Dec 8 '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. –  Sukminder Dec 8 '12 at 21:45
    
I see what you mean, thnx for the explanation. Don't know the answer in this case though. –  jippie Dec 8 '12 at 21:48
show 1 more comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
    
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. –  Sukminder 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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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