#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

set_alternatives_to_intel()
{
	echo "Intel card active."
	update-alternatives --set gl_conf /usr/lib/mesa/ld.so.conf
	ldconfig
	return 0
}

set_alternatives_to_nvidia()
{
	echo "NVidia card active."
	update-alternatives --set gl_conf /usr/lib/nvidia-current/ld.so.conf
	ldconfig
	return 0
}


modprobe sony-laptop 2>/dev/null

#if [ "$(uname -r)" = "2.6.35-rc6-vaioz" -o "$(uname -r)" = "2.6.38-7-generic" ]
if [ -e /sys/devices/platform/sony-laptop/speed_stamina ]
then
	[ "$(cat /sys/devices/platform/sony-laptop/speed_stamina)" = "stamina" ] && set_alternatives_to_intel || set_alternatives_to_nvidia
fi

exit 0
