#!/bin/bash
# Modified by UbuntuXtreme.com
# Author: drpaneas@ubuntuxtreme.com
# Date: 22/08/2012

# Remove Open Source Drivers
sudo rmmod -f vga16fb
sudo rmmod -f nouveau
sudo rmmod -f rivafb
sudo rmmod -f nvidiafb
sudo modprobe -b vga16fb
sudo modprobe -b nouveau
sudo modprobe -b rivafb
sudo modprobe -b nvidiafb
sudo apt-get --purge remove xserver-xorg-video-nouveau
sudo update-initramfs -u


# Remove nVIDIA Proprietary (old)
sudo apt-get purge nvidia* -y
# Remove all nvidia* packages in the system
sudo dpkg -l | grep nvidia | awk '{ print $2 }' | xargs sudo apt-get purge
		 
# Remove all the nvidia kernel objects currently installed
export kernel_version=`uname -r`
sudo rm -f `find /lib/modules/$kernel_version -iname nvidia.ko`

# Add X-Swat PPA
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates 

# Update
sudo apt-get update

# Upgrade
sudo apt-get upgrade -y

# Install (if not installed)
sudo apt-get install xdiagnose xserver-xorg-video-intel

# Install NVIDIA unified
sudo apt-get install nvidia-current -y

# Reboot your PC
sudo shutdown -r 0

