xorg: added support for upgrading X.org configuration from nvidia to nouveau

This commit is contained in:
Silvan Calarco 2011-07-10 17:25:50 +02:00
parent e9c2831bae
commit a00d7555ce

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# xorg - xorg plugin for postplug # xorg - xorg plugin for postplug
# Copyright (c) 2004-2009 by Silvan Calarco <silvan.calarco@mambasoft.it> # Copyright (c) 2004-2011 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Copyright (c) 2004-2007 by Davide Madrisan <davide.madrisan@qilinux.it> # Copyright (c) 2004-2007 by Davide Madrisan <davide.madrisan@gmail.com>
if [ $UID != 0 ]; then if [ $UID != 0 ]; then
echo "$0: must be superuser." >&2 echo "$0: must be superuser." >&2
@ -147,7 +147,7 @@ __EOF
rm -fr /tmp/.ICE-unix rm -fr /tmp/.ICE-unix
install -m 1777 -o root -g root -d /tmp/.ICE-unix install -m 1777 -o root -g root -d /tmp/.ICE-unix
# video detection # video hardware change detection
VIDEO_DEV="`lspci -n | grep " 03[0-9][0-9]: "`" VIDEO_DEV="`lspci -n | grep " 03[0-9][0-9]: "`"
if [ -e $XORGCONF -a -e $postpluglibdir/xorg.cache ]; then if [ -e $XORGCONF -a -e $postpluglibdir/xorg.cache ]; then
@ -158,6 +158,22 @@ if [ -e $XORGCONF -a -e $postpluglibdir/xorg.cache ]; then
} }
fi fi
if [ -e $XORGCONF ]; then
VIDEODRIVERS=(`sed -n "/Section[ \t]\"Device\"/,/EndSection/{s/^[ \t]*Driver[ \t]*\"\(.*\)\"/\1/p}" $XORGCONF`)
# assume first driver as default videodriver
VIDEODRIVER=${VIDEODRIVERS[0]}
if [ "$VIDEODRIVER" = "nvidia" ]; then
[ -e /sys/module/nouveau/parameters/modeset ] && NOUVEAU_MODESET=`cat /sys/module/nouveau/parameters/modeset`
if [ "$NOUVEAU_MODESET" = "1" ]; then
# replace nvidia with nouveau
mv $XORGCONF $XORGCONF.postplug.nvidia.save
rmmod nvidia
echo "blacklist nvidia" > /etc/modprobe.d/postplug-nouveau.conf
fi
fi
fi
if [ ! -e $XORGCONF ]; then if [ ! -e $XORGCONF ]; then
# #
# Create a new Xorg configuration file # Create a new Xorg configuration file