home > how to > linux screengrab anything
Screengrabing whilst running KDE or Gnome is easy but what if you want to screengrab something like a KDM or GDM login screen? Well you can use a utility called xwd which according to it's man page is "an X Window System window dumping utility". First get whatever it is you want to grab on the screen, then log in to the machine via ssh or on a different console either as the same user who owns the display that you'll be grabing or as root. Find the auth file for the display:
$ ps ax | grep `pidof X` root 5630 2.0 3.4 75796 71180 tty7 SLs+ 18:59 2:06 /usr/bin/X -br -nolisten tcp :0 vt7 -auth /var/run/xauth/A:0-ODCG3R
In this case it's /var/run/xauth/A:0-ODCG3R. Then set your XAUTHORITY variable to that, set your DISPAY variable and tell xwd to dump the root window:
$ export XAUTHORITY=/var/run/xauth/A:0-ODCG3R $ export DISPLAY=:0 $ xwd -root > grab.xwdThe resulting.xwd fle can be opened in Gimp or converted to some other format using ImageMagick or other conversion tool. I wrote a script to automate this and convert the grab to png format which I call xsnap.
modified:29th August 2008