How to look at hidden X screens

Updated . Posted . Visible to the public.

When you have a program running in a hidden X screen (like with Xvfb for Selenium tests) you may want to look at that hidden screen occasionally.

First, find out what X displays are currently active:

netstat -nlp | grep X11

This should give you some results like these:

unix  2      [ ACC ]     STREAM     LISTENING     8029600  4086/Xvfb           /tmp/.X11-unix/X99
unix  2      [ ACC ]     STREAM     LISTENING     8616     -                   /tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     8615     -                   @/tmp/.X11-unix/X0
unix  2      [ ACC ]     STREAM     LISTENING     8029599  4086/Xvfb           @/tmp/.X11-unix/X99

In that case displays 0 and 99 are active and you can see that 99 is provided by Xvfb.

Next, simply make a screenshot from that display, e.g. with scrot:

DISPLAY=:99 scrot

This will create a timestamped PNG file in your current directory. You may also pass a custom filename to scrot.
Look at the screenshot with your favorite tool.

Arne Hartherz
Last edit
Arne Hartherz
Keywords
linux, ubuntu, vnc, headless
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2011-07-25 14:01)