#!/bin/bash
## My one-stop setup script

if [ ! -f phase.1 ];
then
        echo "hi">phase.1

        if zenity --question --text="Patch SOURCES.LIST to remove SRC lines?"; then
                #sudo gedit /etc/apt/sources.list 
                sudo sed -i 's/deb-src /#deb-src /g' /etc/apt/sources.list
        else
                echo [** Skipping SOURCES.LIST editing **]
        fi

        zenity --info --text="Screensaver to 15m, disable lock screen"

        zenity --info --text="Change Theme to Clearlooks."

        if zenity --question --text="Dist-upgrade now?"; then
                sudo apt-get update
                sudo apt-get --yes --force-yes dist-upgrade 
                zenity --info --text="You should reboot now"
                exit
        else
                echo [** Skipping Dist-upgrade **]
        fi

else
        echo "Starting Phase 2..."


        if zenity --question --text="Fix the button order in Metacity? (not needed if you changed theme)"; then
		zenity --text="Edit apps/metacity/general/button_layout. Colon is the bulk of titlebar";
                gconf-editor &
        else
                echo [** Skipping Gconf-editor **]
        fi

        if zenity --question --text="Set Medibuntu repository and grab W32codecs/LibDVD stuff?"; then
                ## w32codes etc 
                ## from http://www.ubuntugeek.com/install-mplayer-and-multimedia-codecs-libdvdcss2w32codecsw64codecs-in-ubuntu-10-04-lucid-lynx.html    
                sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list 
                sudo apt-get --quiet update 
                sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring 
                sudo apt-get --quiet update  
                zenity --question --text="Just a delay to make sure that worked...";
                sudo apt-get --yes --force-yes install w32codecs libdvdcss2 ubuntu-restricted-extras
                #sometimes when libdvdcss2 doesn't work, libdvdcss works with a substitution!        
                sudo apt-get --yes --force-yes install libdvdcss
                #one last way, in case previous 2 fail        
                sudo apt-get --yes --force-yes install libdvdread4
                sudo /usr/share/doc/libdvdread4/install-css.sh
        else
                echo [** Skipping Medibuntu section **]
        fi

        if zenity --question --text="Get Conky and Wallpapers?"; then
                wget www.kel.cc/linux/conkyrc
                cp conkyrc ~/.conkyrc
                rm conkyrc
                wget www.kel.cc/linux/wanip.sh
                cp wanip.sh ~/.wanip.sh
                chmod +x ~/.wanip.sh
                rm wanip.sh
                rm conkyrc
                wget www.kel.cc/linux/my_compiz.profile
                cd ~/Pictures
                mkdir wallpapers
                wget www.kel.cc/linux/wallpapers.tar.gz
                cd wallpapers
                tar -xf ../wallpapers.tar.gz
                rm ../wallpapers.tar.gz
                cd ~
                sudo apt-get --yes --force-yes install conky
                wget "www.kel.cc/linux/scripts/start scripts/start_conky.sh"
                chmod +x start_conky.sh
                sudo cp start_conky.sh /etc/init.d
        else
                echo [** Skipping Conky and Wallpapers **]
        fi

        if zenity --question --text="Do you want to downgrade to old Grub? (/dev/sda only)"; then
                sudo apt-get purge grub2 grub-pc
                sudo apt-get install grub
                sudo update-grub
                sudo grub-install /dev/sda
                zenity --info --text="Make sure that worked.  Editing new MENU.LST file.\!"
                sudo gedit /boot/grub/menu.lst
        else
                echo [** Skipping Grub downgrade **]
        fi

        if zenity --question --text="All my usual additional software?"; then
                sudo apt-get --yes --force-yes install flashplugin-installer vlc 
                sudo apt-get --yes --force-yes install dvdrip deluge-torrent parcellite mountmanager
                sudo apt-get --yes --force-yes install preload compizconfig-settings-manager 
		#the next 3 lines are for guayadeque only
		sudo add-apt-repository ppa:anonbeat/guayadeque
		sudo apt-get update
		sudo apt-get --yes --force-yes install guayadeque

        else
                echo [** Skipping usual software additions **]
        fi  

        if zenity --question --text="A few extra games? (burgerspace, lbreakout2, frozen-bubble)"; then
		sudo apt-get --yes --force-yes install burgerspace lbreakout2 frozen-bubble
        else
                echo [** Skipping extra games **]
        fi  

        if zenity --question --text="PDF conversion for the commandline and NZB tools?"; then
                sudo apt-get --yes --force-yes install pdfjam sam2p imagemagick klibido gpar2 mencoder
        else
                echo [** Skipping PDF conversion **]
        fi  
  
        if zenity --question --text="Install all the Google fonts?"; then
                cd && wget http://webupd8.googlecode.com/files/install-google-fonts
                chmod +x install-google-fonts
                ./install-google-fonts        
        else
                echo [** Skipping Google font additions **]
        fi  

        if zenity --question --text="Install my Nautilus scripts?"; then
                cd && cd .gnome2/nautilus-scripts
                wget http://www.kel.cc/linux/scripts/AVImerge
                wget "http://www.kel.cc/linux/scripts/Terminal Here"
                wget http://www.kel.cc/linux/scripts/Checksums/md5sum
		wget http://www.kel.cc/linux/scripts/Checksums/sha256sum
		## wget http://www.kel.cc/linux/scripts/make_packet
		## wget http://www.kel.cc/linux/scripts/make_packet_loop
                chmod +x *
        else
                echo [** Skipping Nautilus scripts **]
        fi  

        if zenity --question --text="Intro video on desktop?"; then
		cd && cd Desktop                
		wget "http://www.kel.cc/linux/Intro.mp4"
        else
                echo [** Skipping intro video **]
        fi  

        if zenity --question --text="Install Mechanig cleaner?"; then
		sudo add-apt-repository ppa:kokoto-java/usu-extras
		sudo apt-get update
		sudo apt-get install mechanig
	else
		echo [** Skipping Mechanig **]
	fi

	zenity --info --text="Other things you should do on your own:\n - Clean unwanted kernels out of Menu.lst\n - Adblock Plus into Firefox\n - Menu Bar transparency\n - Sys/Adm/Hardware Drivers\n - Compiz if desired\n - Add background images, pick one"
 
fi 
       




