File switch2nv of Package x11-tools

#!/bin/sh
# Copyright (c) 2001 SuSE GmbH Nuernberg, Germany.  All rights reserved.
#
# Author: Stefan Dirsch, 2001
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 675 Mass Ave, Cambridge MA 02139, USA.

echo "------------------------------------------------------------------------"
echo "Switching the use of \"nvidia\" driver of NVIDIA to \"nv\" driver of X.Org"
echo "------------------------------------------------------------------------"
echo

if [ "`id -u`" != "0" ]; then
 echo "error: You must be root to use this program!"
 exit 1
fi

libdir="lib"
test "$(arch)" == "x86_64" && libdir="lib64"
for file in /usr/X11R6/$libdir/modules/drivers/nvidia_drv.so \
            /usr/$libdir/xorg/modules/drivers/nvidia_drv.so; do
  if [ -r $file ]; then
    if strings $file | grep -q "NVIDIA dlloader X Driver"; then
      echo    "warning: NVIDIA driver installed. Uninstalling NVIDIA driver first."
      echo -n "warning: Running \"/usr/bin/nvidia-installer --uninstall -s\" ... "
      /usr/bin/tiny-nvidia-installer --uninstall -s
      echo "done"
      echo
      depmod -a &> /dev/null
    fi
  fi
done

echo -n "Patching /etc/X11/xorg.conf ... "
sed -e '/[ \t]*Driver[ \t]*"nvidia"/s/nvidia/nv/g' \
    -e 's/[ \t]*Option[ \t]*"HWCursor"[ \t]*"on"/  Option "HWCursor" "off"/g' \
    -e 's/[ \t]*Option[ \t]*"Composite"[ \t]*"on"/  Option "Composite" "off"/g' \
    -i /etc/X11/xorg.conf
echo "done"
openSUSE Build Service is sponsored by