Tux

...making Linux just a little more fun!

2-cent Tip: Screenshots without X

Kapil Hari Paranjape [kapil at imsc.res.in]


Sat, 21 Mar 2009 07:50:04 +0530

Hello,

I had to do this to debug a program so I thought I'd share it.

X window dump without X

How does one take a screenshot without X? (For example, from the text console)

Use Xvfb (the X server that runs on a virtual frame buffer).

Steps:

  1. Run Xvfb
       $ Xvfb
     This will usually start the X server :99
       $ DISPLAY=:99 ; export DISPLAY
  2. Run your application in the appropriate state.
       $ firefox http://www.linuxgazette.net &
  3. Find out which window id corresponds to your application
       $ xwininfo -name 'firefox-bin' | grep id
     Or
       $ xlsclients
     Use the hex string that you get as window id in the commands
     below
  4. Dump the screen shot of that window
       $ xwd -id 'hexid" > firefox.xwd
  5. If you want to, then kill these applications along with the 
     X server
       $ killall Xvfb

'firefox.xwd' is the screenshot you wanted. Use 'convert' or on of the netpbm tools to convert the 'xwd' format to 'png' or whatever.

Additional Notes:

A. You can use a different screenshot program.

B. If you need to manipulate the window from the command line, then programmes like 'xautomation' and/or 'xwit' are your friends. Alternatively, use a WM like "fvwm" or "xmonad":

  DISPLAY=:99 xmonad &
This will allow you to manipulate windows from the command line if you know some Haskell!

Regards,

Kapil. --


Top    Back


Thomas Adam [thomas.adam22 at gmail.com]


Sat, 21 Mar 2009 11:29:19 +0000

2009/3/21 Kapil Hari Paranjape <[email protected]>:

> Hello,
>
> I had to do this to debug a program so I thought I'd share it.
>
> X window dump without X
> -----------------------
>
> How does one take a screenshot without X? (For example, from the text
> console)
>
> Use Xvfb (the X server that runs on a virtual frame buffer).

Or just use Xephyr. In fact this would be even easier, since there's an additional overhead in using Xvfb.

-- Thomas Adam


Top    Back


Kapil Hari Paranjape [kapil at imsc.res.in]


Sat, 21 Mar 2009 21:00:07 +0530

Hello,

On Sat, 21 Mar 2009, Thomas Adam wrote:

> 2009/3/21 Kapil Hari Paranjape <[email protected]>:
> > Use Xvfb (the X server that runs on a virtual frame buffer).
> 
> Or just use Xephyr.  In fact this would be even easier, since there's
> an additional overhead in using Xvfb.

I thought Xephyr cannot create a virtual display (for example if you are in a text console).

I agree that Xephyr would be better if you want to run this inside an existing X session.

Regards,

Kapil. --


Top    Back