Read more

How to look at hidden X screens

Arne Hartherz
July 25, 2011Software engineer at makandra GmbH

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.

Illustration money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
Read more Show archive.org snapshot

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.

Posted by Arne Hartherz to makandra dev (2011-07-25 16:01)