#!/bin/sh
#
# getXScreenDepth - Return the number of planes of the screen


SCREEN_DEPTH=8

xdpy_cmd=`cmdLocation xdpyinfo`

try_xdpycmd="N"

if [ -f $xdpy_cmd ]
then
    if $xdpy_cmd > /dev/null 2>&1
    then
	try_xdpycmd="Y"
    else
        echo "Could not run xdpyinfo properly to get screen depth."
    fi
else
    echo "Can't find the xdpyinfo command to get screen depth."
fi

if [ "$try_xdpycmd" != "N" ] 
then
	SCREEN_DEPTH=`$xdpy_cmd | grep "depth of root" | awk '{ print $5 }'`
else
	echo
	echo "Please enter the number of planes that your X server typically uses"
	echo "Common values are 1/8/16/24/32 - 1 is black and white, 8 for 8 bit color card."
	echo "If you don't know then try 16."
	echo ""
	echo -n "Enter screen depth: [16] "

	read SCREEN_DEPTH

	if [ -z "$SCREEN_DEPTH" ]
	then
		SCREEN_DEPTH=16
	fi
fi


echo $SCREEN_DEPTH > /tmp/screen_depth.treeps.tmp

