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.
It's probably the fault of the game, not the fault of the screenshot utility. X11 sends applications a VisibilityNotify event to tell them that their window is fully visible, partially obscured or totally obscured. When the window is totally obscured, most applications don't bother updating their display, which saves resources. In other words, if nobody is there to see it, the tree doesn't fall.
I think that if you send the game window a VisibilityNotify event to pretend that it's visible, then you'll get your screenshot. You'll need to send the event after the window becomes obscured, since X11 itself will send its normal event at that time. Here's an untested script that sends a VisibilityNotify event, call it with the argument VisibilityPartiallyObscured
or VisibilityUnobscured
. I follow with a MapNotify
event, I don't know if it's useful. You need Python and Python-xlib.
#! /usr/bin/env python
import re, sys, time
import Xlib.X, Xlib.XK, Xlib.display, Xlib.protocol
def parse_action(string):
state = {
'0': 0,
'1': 1,
'2': 2,
'unobscured': 0,
'partiallyobscured': 1,
'fullyobscured': 2,
'visibilityunobscured': 0,
'visibilitypartiallyobscured': 1,
'visibilityfullyobscured': 2,
}[string.lower()]
return state
def parse_window(display, arg):
wid = int(arg, 0)
return display.create_resource_object('window', wid)
def send_event(display, window, state):
window.send_event(Xlib.protocol.event.VisibilityNotify(window=window,
state=state))
window.send_event(Xlib.protocol.event.MapNotify(window=window,
event=window,
override=False))
display.sync()
if __name__ == "__main__":
display = Xlib.display.Display()
send_event(display, parse_window(display, sys.argv[1]), parse_action(sys.argv[2]))
Best Answer
The format of the raw file you capture is going to depend on the bit depth and resolution.
There are a number of tools out there to do this. Debian has the
fbcat
package. You may need tosudo apt-get install fbcat
to install it.fbcat
will grab the frame buffer inppm
format, so you can then useppmtojpeg
or similar to convert it to the format you want.There's also a
fbgrab
wrapper which will save in PNG format.