#!/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 \"nv\" driver to \"nvidia\" driver"
echo "------------------------------------------------------------------------"
echo

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

head -n 2 /etc/X11/xorg.conf | tail -n 1 | grep "^# SaX"
if [ $? -eq 0 ]; then
  echo -n "Patching /etc/X11/xorg.conf ... "

  tmpfile=`mktemp /tmp/xorg.conf.XXXXXXXXXX`
  cp /etc/X11/xorg.conf $tmpfile
  sed -e s/\"nv\"/\"nvidia\"/g $tmpfile > /etc/X11/xorg.conf
  echo "done"

  rm -f $tmpfile
else
  echo "SaX2 generated xorg.conf not available!"
fi
