#!/bin/bash
#
# This program comes with no warranties specific or implied. I tested the heck out of
#+ it on my own system but I make no promises it won't turn yours into the fluffy tail of 
#+ an atomic/radioactive hamster(R)(TM) 
#
# Right now it just replaces all the files so you shouldn't run it unless you're on a newly 
#+ formated system unless you want to risc having to repair some settings 
#
# Tried to make it as clean and straight forward as posible, hence all the comments.
# If there's something about this script you don't like you can fix it yourself and bugger
#+ off ;). That's all folks,
# 										Cheers!

menu ()
{
	clear # Clears the screen
	
	# Draw the menu
	echo;	echo "(F) Enable Full Desktop (KDE)"
	
	echo;	echo "(S) Disable SCIM (chinese keyboard input option / on by default)"
	
	echo;	echo "(R) Enable extra repos (overrides custom repositories)"
	
	echo 

	#If the multimedia repository is enabled - allow the installation of mplayer
	if cat /etc/apt/sources.list | grep http://www.debian-multimedia.org; then
		echo "(C) Enable all codec support (Repository found!)";	echo
	else
		echo "Enable all codec support (Extra repos must be enabled!)"; echo
	fi

	echo "(1) Install cool Black theme"
	echo "(2) Install cool Mac theme"

	echo;	echo "(3) Remove the SOS and Eee PC Tips from toolbar"

	echo;	echo "(4) Add camera on and off scripts"
	
	echo;	echo "(Q) Quit"

	echo
	echo
	echo

	echo "My choice is: "	
	read choice # Get the user's choice
	
	clear
	case "$choice" in
		"f" | "F" ) # Enable the full desktop
			cd /tmp

			echo "Updating sources..."
			sudo apt-get update
			echo "Installing the KDE environment..."
			sudo apt-get install kicker ksmserver
			echo "Full desktop enabled"
			echo
			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
	 	;;

		"s" | "S" ) # Disable SCIM by uninstalling the Xandros-SCIM package
			echo "Removing xandros-scim package..."
			sudo apt-get remove xandros-scim
			echo "SCIM removed (Restart recomended)"
			echo

			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
		;;

		"r" | "R" ) # Enable extra repos (replace sources.list)
			cd /tmp

			echo "Creating custom sources.list..."
			echo "# Standard repos" >> .sources
			echo "deb http://update.eeepc.asus.com/p701/ p701 main" >> .sources
			echo "deb http://update.eeepc.asus.com/p701/en/ p701 main" >> .sources
			echo >> .sources
			echo "# Comunity repos that should be great but just messes with my system" >> .sources
			echo "#deb http://download.tuxfamily.org/eeepcrepos/ p701 main etch" >> .sources
			echo >> .sources
			echo "# Xandros repos" >> .sources
			echo "deb http://xnv4.xandros.com/xs2.0/upkg-srv2 etch main contrib non-free" >> .sources
			echo "deb http://dccamirror.xandros.com/dccri/ dccri-3.0 main" >> .sources
			echo "deb http://www.geekconnection.org/ xandros4 main" >> .sources
			echo >> .sources
			echo "# Debian repos" >> .sources
			echo "deb http://http.us.debian.org/debian/ etch main contrib non-free" >> .sources
			echo "deb http://www.debian-multimedia.org etch main" >> .sources

			echo "Overwriting original..."
			sudo mv .sources /etc/apt/sources.list

# As a safety measure, the program creates a preferences file to make sure that Xandros packages 
#+are prefered to the ones that are found in the Debian Etch repos. If you decide to install a 
#+specific version of a file (by downloading it and doing a dpkg -i packagename) it makes sure that 
#+it doesn't install dependencies that would break the system(or at least it tries). If the package 
#+you decide to install brakes the system all by it's self it has no protection whatsoever, sorry;( 

			echo "Pinning..."
			echo "Package: *" >> .apt.preferences
			echo "Pin: origin update.eeepc.asus.com" >> .apt.preferences
			echo "Pin-Priority: 950" >> .apt.preferences
			echo >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			echo "Pin: origin" >> .apt.preferences
			echo "Pin-Priority: 925" >> .apt.preferences
			echo >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			echo "Pin: origin xnv4.xandros.com" >> .apt.preferences
			echo "Pin-Priority: 900" >> .apt.preferences
			echo >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			echo "Pin: origin dccamirror.xandros.com" >> .apt.preferences
			echo "Pin-Priority: 850" >> .apt.preferences
			echo >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			echo "Pin: origin www.geekconnection.org" >> .apt.preferences
			echo "Pin-Priority: 750" >> .apt.preferences
			echo >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			echo "Pin: release a=stable" >> .apt.preferences
			echo "Pin-Priority: 700" >> .apt.preferences
			echo >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			echo "Pin: release a=testing" >> .apt.preferences
			echo "Pin-Priority: 650" >> .apt.preferences
			echo >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			echo "Pin: release a=unstable" >> .apt.preferences
			echo "Pin-Priority: 600" >> .apt.preferences
			echo "Package: *" >> .apt.preferences
			
			sudo mv .apt.preferences /etc/apt/preferences			

			echo "Retrieving new package lists..."
			sudo apt-get update
			
			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
		;;
	
		"c" | "C" ) # Install an older version of mplayer that should have full codec support including h.264
			if cat /etc/apt/sources.list | grep http://www.debian-multimedia.org; then
				sudo aptitude install mplayer=1.0~rc1-12etch1
				echo
				echo "Press Enter to return to menu"	
				read
			fi
			menu # Reset the menu
	 	;;

		"1" ) # Download and install thinblack
			cd /tmp

			echo "Downloading ThinBlack..."
			wget -t 0 -c http://themes.freshmeat.net/redir/thinblack/67777/url_tgz/thinblack-default-1.5.tar.gz
			
			echo "Unpacking theme..."
			tar -vxzf thinblack-default-1.5.tar.gz
			
			echo "Installing theme..."
			sudo mv ThinBlack /usr/share/icewm/themes/ThinBlack			
			
			echo "Setting theme preferences..."
			mkdir ~/.icewm
			echo 'Theme="ThinBlack/default.theme"' > .theme
			mv .theme ~/.icewm/theme

			echo "Restart required"

			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
		;;

		"2" ) # Download and install SmoothyFeelings
			cd /tmp

			echo "Downloading Smoothy Feelings..."
			wget -t 0 -c http://themes.freshmeat.net/redir/smoothyfeelings/45049/url_tgz/smoothyfeelings-default-1.0.1.tar.gz
			
			echo "Unpacking theme..."
			tar -vxzf smoothyfeelings-default-1.0.1.tar.gz			
			
			echo "Installing theme..."
			sudo mv Smooth-Feelings /usr/share/icewm/themes/Smooth-Feelings			

			echo "Setting theme preferences..."
			mkdir ~/.icewm
			echo 'Theme="Smooth-Feelings/default.theme"' > .theme
			mv .theme ~/.icewm/theme

			echo "Restart required"

			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
		;;

		"3" ) #Remove extra icons from the tray
			cd /tmp

			echo "Making new configuration..."
			echo 'prog "Shutdown" shutdown /opt/xandros/bin/shutdown_dialog shutdown' >> .toolbar2
			mkdir ~/.icewm
			mv .toolbar2 ~/.icewm/toolbar2
			echo "Restart required"
			
			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
		;;

		"4" ) # Add camera scripts
			cd /tmp
			echo "Making the scripts..."
			echo 
			
			echo "sudo echo 1 > /proc/acpi/asus/camera" >> .camon
			chmod +x .camon
			echo "sudo echo 0 > /proc/acpi/asus/camera" >> .camoff
			chmod +x .camoff
			
			echo "Placing the scripts..."
			echo

			sudo mv .camon /usr/bin/camon
			sudo mv .camoff /usr/bin/camoff
			
			echo "The scripts are created" 
			echo "camon or camoff from the terminal will turn the camera on or off"
			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
		;;
	
		"Q" | "q" ) # Quit this wonderous world of EeeNirvana
			clear
			echo Bye!
			exit 0
		;;

		* ) # Wrong input
			menu # Reset the menu
		;;
	esac
}

menu

# This program will achieve 
#+ GLOBAL DOMINATION!!!
#+ MUHAHAHAHA!!!

