#!/bin/bash xwdfile=/tmp/xsnap.xwd pngfile=xsnap.png xpid=`pidof X` authfile=`ps h $xpid | awk '{print $12}'` export XAUTHORITY=$authfile export DISPLAY=:0 xwd -root > $xwdfile # if imagemagick is installed then convert the grab to png if [ -z "`which convert 2>/dev/null`" ];then cp $xwdfile . && echo "file writtem as `basename $xwdfile`" else convert $xwdfile $pngfile && echo "file writtem as $pngfile" fi rm -f $xwdfile