#!/bin/bash
#
# This program comes with no warranties specific or implied. I tested it extensively
#+ 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 ;). Just kidding. Please tell me if you do find errors or have suggestions. 
#						That's all folks,
# 										Cheers!

menu ()
{
	clear # Clears the screen
	
	# Draw the menu
	echo # blank

	echo "(1) Enable Full Desktop (KDE)"
	echo
	echo "(2) Enable all codec support"
	echo
	echo "(3) Disable SCIM (chinese keyboard input option / on by default)"
	echo
	echo "(4) Enable extra repos (overrides custom repositories)"
	echo 
	echo "(5) Install cool Black theme"
	echo "(6) Install cool Mac theme"
	echo
	echo "(7) Remove the SOS and Eee PC Tips from toolbar"
	echo
	echo "(8) Add camera on and off scripts"
	echo
	echo "(q) Quit"
	echo
	echo
	echo
	echo "My choice is: "	
	read choice # Get the user's choice

	case "$choice" in
		"1" ) # 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
	 	;;

		"2" ) # Install an older version of mplayer that should have full codec support including h.264
			echo "Extra repositories MUST be enabled"
			sudo aptitude install mplayer=1.0~rc1-12etch1
			echo
			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
	 	;;

		"3" ) # 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
		;;

		"4" ) # 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 up 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 "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
		;;
	
		"5" ) # 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
		;;

		"6" ) # 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
		;;

		"7" ) #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
		;;

		"8" ) # 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 "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
			echo "Invalid input"
			echo
			echo "Press Enter to return to menu"	
			read
			menu # Reset the menu
		;;
	esac
}

menu

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