echo Your GPU:
lspci | egrep -i --color '3D controller|vga'
while :
do

	# Choose your GPU
	read -p "What is your GPU brand? [intel/nvidia/amd/other/back/exit] " gpu
	case $gpu in

		# Intel driver installation
		intel) apt-get install -y xserver-xorg-video-intel
		echo All is good! Intel GPU have a good support from Intel.
		break;;

		# Nvidia driver installation
		nvidia)
		while :
		do
			read -p "Nouveau open source driver or Nvidia proprietary driver? If you are in a laptop, add '-optimus' after to install Bumblebee that enable this feature. For more informations, write '?' [nouveau/nvidia/?/back](-optimus) " nv
			case $nv in

				# Bumblebee Optimus support
				# Add a command to use Optimus with optimized performances, stolen from https://askubuntu.com/questions/297596/vblank-mode-0-primusrun-in-application-desktop-file/321595#321595
				*-optimus) apt-get install -y bumblebee
				[ $nv = nvidia ] && apt-get install -y nvidia-driver bumblebee-nvidia
				echo 'vblank_mode=0 primusrun "$@"' >> /usr/bin/optiprime
				chmod +x /usr/bin/optiprime
				cat > /etc/bumblebee/xorg.conf.nvidia <<EOF
				Section "Screen"
				    Identifier "Default Screen"
				    Device "DiscreteNvidia"
				EndSection
EOF
				echo "You can now switch to the dedicated Nvidia GPU with the 'optiprime <programm>' command. This 'optiprime' command allow more performance than the traditionals 'primusrun' and 'optirun' commands"
				break;;

				# Nvidia proprietary driver
				nvidia) apt-get install -y nvidia-driver
				apt-get install -y nvidia-driver
				echo Nvidia driver installed!
				break;;

				# Nouveau open source driver
				nouveau) echo Normally all is fine!
				break;;

				back) break;;

				# Informations
				?) echo "Nouveau is a libre and open source driver, while nVidia is proprietary and has generally better performance. Bumblebee is an implementation of Nvidia Optimus. The integrated Intel GPU is alaways active to save energy. For more performance, switch to the dedicated nVidia GPU with 'optiprime <programm>'";;
			esac
		done
		break;;

		# AMD driver installation
		amd)
		while :
		do
			read -p "Nouveau open source driver or AMD proprietary driver? Write '?' for more informations [open-source/proprietary/?] " amd
			case $amd in

				# AMD open source driver
				open-source) apt-get install -y firmware-linux-nonfree libgl1-mesa-dri xserver-xorg-video-ati
				break;;

				# AMD proprietary driver
				proprietary) apt-get install -y fglrx-driver
				break;;

				# Informations
				?) echo "Nouveau is a libre and open source driver, while Nvidia is proprietary and has generally better performance. Bumblebee is an implementation of Nvidia Optimus. The integrated Intel GPU is alaways active to save energy. For more performance, switch to the dedicated nVidia GPU with optiprime <programm>";;
			esac
		done
		break;;

		# Other
		other) echo Sorry, but your GPU is not supported by this script yet! ;break;;

		back) break;;
		exit*) exit;;
		*) echo Invalid answer.;;
	esac
done
