How to take screenshot of an X11 based GUI from a text terminal (such as tty1)?
In addition to the existing answers, to display the screenshot in ASCII in the terminal:
xwd -root -display :0 | convert - jpg:- | jp2a - --colors
(Requires x11-apps
for xwd
, imagemagick
for convert
and jp2a
.)
Here is solution using xwd
, which is is available in almost all Xorg installations:
xwd -root -out screenshot.xwd
The screenshot.xwd
file can be opened with GIMP:
For more info see http://www.x.org/wiki/UserDocumentation/GettingStarted/.
Try using shutter
DISPLAY=:0 shutter -f -e -n -o "$HOME/Pictures/screenshot.png"
Import won't work, because the root window is not in use. Compositing "bypasses" it (each window is rendered in its own buffer then multiplexed to the display, instead of the old way, where they were all rendered on the "root" window).
In addition you need to make sure the VTY is active before you take the screenshot. So for example,
#!/bin/bash
X :1 &
export DISPLAY=:1
sleep 10 # give time for X to start
gedit &
sleep 10 # give time for app to do something
chvt 8 # ensure the X display is active
shutter -f -e -n -o "$HOME/Pictures/screenshot.png" # screenshot
killall xorg # terminate X