#!/bin/bash
echo "	La version francaise a ete abandonnee pour le moment"
echo "	Mais elle reviendra bientot"
echo "     Auto install for Xgl/Glitz/Compiz"
echo "	   Writed by Sonique :: Cedric FERRY"
echo "     Monday  April, 17 2006 v 0.5.3"
echo ""
echo "     http://sonique54.free.fr/xgl/xgl.htm"
echo ""
echo "	   Updated thuesday september , 30 2006"
echo ""
echo "	   Script under GNU/GPL http://www.fsf.org/licensing/licenses/gpl.html"
echo ""
echo ""
echo " 	Warning : This script ABSOLUTELY NO WARRANTY, 
	Author  can't be in charge of any bug, crash, errors..."
echo "	You need Driver for your graphic card (Nvidia, ATI or Intel)"
echo "	1GhZ computer with Geforce 2 or more"
echo "	This Script work with Gnome only"
echo "	If you have some problem please read F.A.Q."
echo "	http://sonique6784.blogspot.com/2006/05/faq-frequently-asked-questions.html"
echo ""
if [ `whoami` != "root" ]; then
	echo "You must be root to execute this scrit please su before. "
	echo "This script have been writed by Cedric FERRY :: Sonique"
	echo "         http://sonique54.free.fr"
	echo "################################################################"
	exit
fi
echo "	push CTRL-C to cancel setup (10secondes)"
sleep 10 
echo "                 *Setup is starting*"
here=`pwd`
echo "creating tempory folder for packages ("$here"/xgl)"
mkdir xgl
cd xgl
echo "Alien setup (program which convert rpms to debs)"
apt-get update && apt-get install alien
echo "Libx* setup (needed for effects)"
apt-get install libdrm2 libpng3 libxdamage1 libxcomposite1 libxfixes3 libxrender1
echo "Libwnck setup"
apt-get install libwnck18 libwnck-common

echo "LibGlitz Setup"
apt-get install libglitz1 libglitz1-dev libglitz-glx1 libglitz-glx1-dev
echo "Packages downloading (Xgl, Compiz, LibSVG, LibRSVG,"
echo "Compiz-Manager, Compiz-Settings-Manager, Compiz-Themes, Libwnck...)"
wget http://sonique54.free.fr/xgl/rpms/compiz-cvs.rpm
wget http://sonique54.free.fr/xgl/rpms/.compiz.png 2&>/dev/null
wget http://sonique54.free.fr/xgl/rpms/libsvg-0.1.4.rpm
wget http://sonique54.free.fr/xgl/rpms/libsvg-devel-0.1.4.rpm
wget http://sonique54.free.fr/xgl/rpms/libsvg-cairo-0.1.6.rpm
wget http://sonique54.free.fr/xgl/rpms/libsvg-cairo-devel-0.1.6.rpm
wget http://sonique54.free.fr/xgl/rpms/librsvg-2.14.rpm
wget http://sonique54.free.fr/xgl/rpms/compiz-manager-cvs.rpm
wget http://sonique54.free.fr/xgl/rpms/cgwd-themes-cvs.rpm
wget http://sonique54.free.fr/xgl/rpms/csm-cvs.rpm
wget http://sonique54.free.fr/xgl/rpms/xgl-cvs.rpm
wget http://sonique54.free.fr/xgl/rpms/xgl-libs.tgz
wget http://sonique54.free.fr/xgl/rpms/libwnck-common_2.16.0-1_all.deb
wget http://sonique54.free.fr/xgl/rpms/libwnck18_2.16.0-1_i386.deb
echo "Convert RPM to Deb"
alien *.rpm
echo "Setup Debian packages"
dpkg -i *.deb --force-overwrite
mv .compiz.png /usr/share/compiz/cubecaps.png
thispath=`pwd`/xgl-libs.tgz
gdmpath=/etc/gdm/gdm.conf
cd /usr/lib
echo "Setup Xgl Libraries"
tar xfvz $thispath
apt-get install libfontenc-dev libfontenc1 libxfont1 libxfont-dev

cd $here 

echo "Do you want use Xgl by default (using ln -s method) 
OBSOLETE (please use gdm.conf)? y/n"

read REPLY
if [ $REPLY = "y" ]; then
        echo "Installing Xgl by default"
        cd /etc/X11/
        mv X X.old
        ln -s /usr/X11R6/bin/Xgl X
        cd /root/
	echo "to come back to Xorg : "
	echo "# cd /etc/X11; mv X.old X "
fi

if [ $REPLY = "n" ]; then
        echo "You can do it laster look on my web site"
        echo "http://sonique54.free.fr/xgl/xgl.htm"
fi


echo "Do you want launch Xgl now ? y/n"

read REPLYXGL
if [ $REPLYXGL = "y" ]; then
	echo "Launching Xgl"
	/etc/init.d/gdm stop
	sleep 2
	##### Launch XGL Xserver ####
	Xgl :0 -fp /usr/share/fonts/X11/misc -ac -accel glx:pbuffer -accel xv:fbo:0 & sleep 5;
	##### Launch Gnome #### 
	DISPLAY=:0 gnome-session &
	#### Launch Compiz (this thing create effect (cube fade...) #### 
	sleep 30;	
	DISPLAY=:0 compiz-start &
	DISPLAY=:0 compiz-manager &
fi

compizstart=/etc/compiz.start
echo "Write compiz start file : " $compizstart
echo "#!/bin/bash
# Compiz Start by Sonique
# http://sonique54.free.fr/xgl/xgl.htm
compiz-start &
compiz-manager &
# You can add Kiba-dock or some other program here
" > $compizstart
chmod a+rx $compizstart

echo "Add XglbySonique in " $gdmpath
cat $gdmpath | grep XglbySonique
$rez=$?
if [ $rez -eq 1 ]; then
	echo "[server-XglbySonique]
#created by Cedric FERRY : Sonique | http://sonique54.free.fr
name=XglbySonique 
command=/usr/X11R6/bin/Xgl :0 -ac -accel glx:fbo:0 -accel xv:fbo -fp /usr/share/fonts/X11/misc
flexible=true" >> /etc/gdm/gdm.conf
	echo "to use Xgl by default edit " $gdmpath
	echo "change 0=Standard by 0=XglbySonique (line ~58)"
else
	echo $gdmpath " is already up to date
fi
echo ""
echo "Xgl and Compiz are now installed, you can configure gnome to launch"
echo "Compiz at session start : "
echo "Desktop > Preferences > Sessions"
echo "Start program > Add"
echo $compizstart
echo ""
echo "This script have been writed by Cedric FERRY :: Sonique"
echo "         http://sonique54.free.fr"
echo "################################################################"


