diff --git a/postplug.d/30xorg b/postplug.d/30xorg index d9808fb..db69f12 100644 --- a/postplug.d/30xorg +++ b/postplug.d/30xorg @@ -1,7 +1,7 @@ #!/bin/bash # xorg - xorg plugin for postplug -# Copyright (c) 2004-2009 by Silvan Calarco -# Copyright (c) 2004-2007 by Davide Madrisan +# Copyright (c) 2004-2011 by Silvan Calarco +# Copyright (c) 2004-2007 by Davide Madrisan if [ $UID != 0 ]; then echo "$0: must be superuser." >&2 @@ -147,7 +147,7 @@ __EOF rm -fr /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]: "`" if [ -e $XORGCONF -a -e $postpluglibdir/xorg.cache ]; then @@ -158,6 +158,22 @@ if [ -e $XORGCONF -a -e $postpluglibdir/xorg.cache ]; then } 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 # # Create a new Xorg configuration file