File switch-libGL.sh of Package x11-video-nvidia
#!/bin/bash
#
#
#
# Check rights
#
if (( EUID != 0 )); then
echo "You do not have sufficient privileges to switch the libGL and libGLESv2 library"
echo
if which sudo &>/dev/null; then
echo "Please run: sudo $0 [ mesa | nvidia ] [ 32 | 64 ]"
else
echo "Please run $0 [ mesa | nvidia ] [ 32 | 64 ] as root"
fi
echo
exit 1
fi
#
# Library names
#
MESA_LIBGL=libGL.so.1.2.0
MESA_LIBGLESV2=libGLESv2.so.2.0.0
NVIDIA_LIBGL=libGL.so.nvidia_version
NVIDIA_LIBGLESV2=libGLESv2.so.nvidia_version
#
# 32bit switch libGL.so
#
if [ -f /usr/lib/$MESA_LIBGL ] && ( [ "x$2" == "x" ] || [ "x$2" == "x32" ] ) ; then
if ( [ "x$1" == "x" ] || [ "x$1" == "xmesa" ] ) && [ -L /usr/lib/$MESA_LIBGL ] ; then
#
# Switch to Mesa
#
rm -f /usr/lib/$MESA_LIBGL
mv -f /usr/lib/nvidia/$MESA_LIBGL.backup /usr/lib/$MESA_LIBGL
elif ( [ "x$1" == "x" ] || [ "x$1" == "xnvidia" ] ) && [ ! -L /usr/lib/$MESA_LIBGL ] ; then
#
# Switch to nVidia
#
mv -f /usr/lib/$MESA_LIBGL /usr/lib/nvidia/$MESA_LIBGL.backup
ln -sf /usr/lib/nvidia/$NVIDIA_LIBGL /usr/lib/$MESA_LIBGL
fi
fi
#
# 32bit switch libGLESv2.so
#
if [ -f /usr/lib/$MESA_LIBGLESV2 ] && ( [ "x$2" == "x" ] || [ "x$2" == "x32" ] ) ; then
if ( [ "x$1" == "x" ] || [ "x$1" == "xmesa" ] ) && [ -L /usr/lib/$MESA_LIBGLESV2 ] ; then
#
# Switch to Mesa
#
rm -f /usr/lib/$MESA_LIBGLESV2
mv -f /usr/lib/nvidia/$MESA_LIBGLESV2.backup /usr/lib/$MESA_LIBGLESV2
elif ( [ "x$1" == "x" ] || [ "x$1" == "xnvidia" ] ) && [ ! -L /usr/lib/$MESA_LIBGLESV2 ] ; then
#
# Switch to nVidia
#
mv -f /usr/lib/$MESA_LIBGLESV2 /usr/lib/nvidia/$MESA_LIBGLESV2.backup
ln -sf /usr/lib/nvidia/$NVIDIA_LIBGLESV2 /usr/lib/$MESA_LIBGLESV2
fi
fi
if [ "`uname -m`" != "x86_64" ] ; then
exit 0
fi
#
# 64bit switch libGL.so
#
if [ -f /usr/lib64/$MESA_LIBGL ] && ( [ "x$2" == "x" ] || [ "x$2" == "x64" ] ) ; then
if ( [ "x$1" == "x" ] || [ "x$1" == "xmesa" ] ) && [ -L /usr/lib64/$MESA_LIBGL ] ; then
#
# Switch to Mesa
#
rm -f /usr/lib64/$MESA_LIBGL
mv -f /usr/lib64/nvidia/$MESA_LIBGL.backup /usr/lib64/$MESA_LIBGL
elif ( [ "x$1" == "x" ] || [ "x$1" == "xnvidia" ] ) && [ ! -L /usr/lib64/$MESA_LIBGL ] ; then
#
# Switch to nVidia
#
mv -f /usr/lib64/$MESA_LIBGL /usr/lib64/nvidia/$MESA_LIBGL.backup
ln -sf /usr/lib64/nvidia/$NVIDIA_LIBGL /usr/lib64/$MESA_LIBGL
fi
fi
#
# 64bit switch libGLESv2.so
#
if [ -f /usr/lib64/$MESA_LIBGLESV2 ] && ( [ "x$2" == "x" ] || [ "x$2" == "x64" ] ) ; then
if ( [ "x$1" == "x" ] || [ "x$1" == "xmesa" ] ) && [ -L /usr/lib64/$MESA_LIBGLESV2 ] ; then
#
# Switch to Mesa
#
rm -f /usr/lib64/$MESA_LIBGLESV2
mv -f /usr/lib64/nvidia/$MESA_LIBGLESV2.backup /usr/lib64/$MESA_LIBGLESV2
elif ( [ "x$1" == "x" ] || [ "x$1" == "xnvidia" ] ) && [ ! -L /usr/lib64/$MESA_LIBGLESV2 ] ; then
#
# Switch to nVidia
#
mv -f /usr/lib64/$MESA_LIBGLESV2 /usr/lib64/nvidia/$MESA_LIBGLESV2.backup
ln -sf /usr/lib64/nvidia/$NVIDIA_LIBGLESV2 /usr/lib64/$MESA_LIBGLESV2
fi
fi
exit 0