← Back to team overview

sony-vaio-z-series team mailing list archive

Better graphics card switching script

 

Hi all,

I have experienced regular breakage of OpenGL programs due to the
following reason: Following the tutorial on switching graphics cards
we have
	/usr/lib/libGL.so.1.INTEL	(intel)
	/usr/lib/libGL.so.185.NN.MM	(nvidia)
The current code from the tutorial (switch-graphics init file) does:
	ln -sf /usr/lib/libGL.so.1.INTEL /usr/lib/libGL.so.1
in the Intel case.

Now the problem is that 185 > 1, so calling ldconfig will revert that
change. So after running ldconfig we have
	/usr/lib/libGL.so.1 -> libGL.so.185.NN.MM
although running Intel card.

I have changed the code as follows: In both cases we create a link
	/usr/lib/libGL.so.100000 -> libGL.so.1.INTEL
or
	/usr/lib/libGL.so.100000 -> libGL.so.185.NN.MM
and then a link
	/usr/lib/libGL.so.1      -> libGL.so.10000

That way calling ldconfig will not destroy the libGL.so.1 link
(unless nVidia comes out with a version higher than 10000 ;-)

I attach the script I am using ATM.


Ah, in additon I have added -q to the grep option in the beginning
so that the output is supressed and only the return code given.

Best wishes

Norbert

-------------------------------------------------------------------------------
Dr. Norbert Preining <preining@xxxxxxxx>        Vienna University of Technology
Debian Developer <preining@xxxxxxxxxx>                         Debian TeX Group
gpg DSA: 0x09C5B094      fp: 14DF 2E6C 0307 BE6D AD76  A9C0 D2BF 4AA3 09C5 B094
-------------------------------------------------------------------------------
ERIBOLL (n.)
A brown bubble of cheese containing gaseous matter which grows on
welsh rarebit. It was Sir Alexander Flemming's study of eribolls which
led, indirectly, to his discovery of the fact that he didn't like
welsh rarebit very much.
			--- Douglas Adams, The Meaning of Liff
#!/bin/sh
lspci | grep -q "00:02.0"
# if we find the Intel chipset, use Intel drivers & settings
if [ $? -eq 0 ]; then
	logger "Setting graphics card to INTEL"
	cp /etc/X11/xorg.conf.INTEL /etc/X11/xorg.conf
	ln -sf /usr/lib/libGL.so.1.INTEL /usr/lib/libGL.so.100000
	ln -sf /usr/lib/libGL.so.100000 /usr/lib/libGL.so.1
	ln -sf /usr/lib/xorg/modules/extensions/libglx.so.INTEL /usr/lib/xorg/modules/extensions/libglx.so
	# this one saves a lot of energy!
	echo stamina > /sys/devices/platform/sony-laptop/speed_stamina
	# modprobe nvidia-control
else
	# otherwise use nVidia drivers & settings
	logger "Setting graphics card to NVIDIA"
	cp /etc/X11/xorg.conf.NVIDIA /etc/X11/xorg.conf
	ln -sf /usr/lib/libGL.so.185.18.31 /usr/lib/libGL.so.100000
	ln -sf /usr/lib/libGL.so.100000 /usr/lib/libGL.so.1
	ln -sf /usr/lib/xorg/modules/extensions/libglx.so.185.18.31 /usr/lib/xorg/modules/extensions/libglx.so
	echo speed > /sys/devices/platform/sony-laptop/speed_stamina
fi


Follow ups