All pastes #903378 Raw Edit

xorgconf.sh

public shellscript v1 · immutable
·published 2008-02-14 06:31 UTC
rendered paste body
#!/bin/shDEBUG=1outDebug() {    if [ -z "$DEBUG" ]; then return    fi    echo -ne '\e\033[01;33m[debug]\e\033[01;00m '    echo "$1"}outWarn() {    echo -ne '\e\033[01;31m[WARNING]\e\033[01;00m '    echo "$1"}xorgSelectCard() {    if [ "$1" == "$xorgDrv" ];    then return    fi    echo Настройка иксов...    mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak    cat /etc/X11/xorg.conf|sed  "s/^[ 	]\+Device[ 	]\+\"[a-z]\+\"/	Device \"$1\"/" > /etc/X11/xorg.conf}radeon() {# переделать    modprobe radeon    modprobe drm    if ! eselect opengl list|grep \*|grep xorg-x11>/dev/null;    then eselect opengl set xorg-x11	    fi}fglrx() {# переделать    modprobe fglrx    if ! eselect opengl list|grep \*|grep ati>/dev/null;    then        eselect opengl set ati        if [ -e /etc/X11/xorg.conf ]        then            if ! [ -h /etc/X11/xorg.conf ]            then mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak            else rm /etc/X11/xorg.conf            fi        fi        ln -s /etc/X11/xorg.conf.atinew /etc/X11/xorg.conf    fi}getNVinfo() {    NV_LEGACY_VER_1="71.86.01"    NV_LEGACY_VER_2="96.43.01"        local LEGACY_CARDS_1="0020 0028 0029 002c 002d 00a0 0100 0101 0103 0150 0151 0152 0153"    local LEGACY_CARDS_2="0110 0111 0112 0113 0170 0171 0172 0173 0174 0175 0176 0177 0178 0179 017a 017c 017d 0181 0182 0183 0185 0188 018a 018b 018c 01a0 01f0 0200 0201 0202 0203 0250 0251 0253 0258 0259 025b 0280 0281 0282 0286 0288 0289 028c"        nvDriver="`echo /var/db/pkg/x11-drivers/nvidia-drivers*|sed 's/^.*nvidia-drivers-\([0-9_\-]\+\)/\1/'`"        if echo "$LEGACY_CARDS_1"|grep "$pciIDl">/dev/null;    then nvDriverNeeded="$LEGACY_VER_1"    elif echo "$LEGACY_CARDS_2"|grep "$pciIDl">/dev/null;    then nvDriverNeeded="$LEGACY_VER_2"    else nvDriverNeeded="last"    fi}setupNV() {    if [ "$nvDriverNeeded" == "last" ] && [ "$nvDriver" != "$NV_LEGACY_VER_1" ] && [ "$nvDriver" != "$NV_LEGACY_VER_2" ];    then	# размаскировать nvidia-drivers и поставить последние из бинарного пакета    elif [ "$nvDriver" != "$nvDriverNeeded" ];    then	# замаскировать nvidia-drivers >= $nvDriverNeeded и поставить    fi        if ! eselect opengl list|grep \*|grep nvidia>/dev/null;    then        eselect opengl set nvidia    fi        xorgSelectCard nvidia}prepareNV() {    modprobe nvidia    # тут можно сделать пересборку дров если модуль не грузится}getInfo() {    devLine="`lspci -nn|grep '\[0300\]'`"    outDebug "Device found: $devLine"    devCount=`echo "$devLine"|wc -l`    if [ "$devCount" -gt 1 ];    then	outWarn "Found more then one video card. Using first."	devLine="`echo "$devLine"|head -n 1`"    fi    pciAddr="`echo "$devLine"|sed 's/^\([0-9_a-f]\+:[0-9_a-f]\+\.[0-9_a-f]\+\).*$/\1/'`"    pciName="`echo "$devLine"|sed 's/^.*\[0300\]: \(.*\) \[[0-9_a-f]\+:[0-9_a-f]\+\]/\1/'`"    pciID="`echo "$devLine"|sed 's/^.*\[\([0-9_a-f]\+:[0-9_a-f]\+\)\].*$/\1/'`"    pciIDh="`echo $pciID|sed 's/\([0-9_a-f]\+\):.*$/\1/'`"    pciIDl="`echo $pciID|sed 's/^.*:\([0-9_a-f]\+\)$/\1/'`"    outDebug "PCI ADDR: $pciAddr"    outDebug "PCI NAME: $pciName"    outDebug "PCI ID:   $pciIDh:$pciIDl"        xorgDrv="`cat /etc/X11/xorg.conf|grep '^[ 	]\+Device[ 	]\+"\([a-z]\+\)".*$'|sed 's/^[ 	]\+Device[ 	]\+"\([a-z]\+\)".*$/\1/'`"    outDebug "active X.Org driver: $xorgDrv"        libGL="`eselect opengl show`"    outDebug "active OpenGL implementation: $libGL"        case "$pciIDh" in	1002) # ATI	;;	10de) # nVidia	    getNVinfo	;;	163c) # Intel	;;    esac        exit# дальше старый код    vcard="`lspci|grep VGA|sed 's/.*: //'`"    echo -e 'Video card: \e\033[01;32m\e' $vcard'\e\033[00m\e '    if echo $vcard|grep nVidia>/dev/null;    then        model=`echo $vcard|sed 's/.*NV\([0-9]\+\) .*/\1/'`        nvidia    fi    if echo $vcard|grep ATI>/dev/null;    then        model=`echo $vcard|sed 's/.*RV\([0-9]\+\) .*/\1/'`        echo " $model"        if [ "$model" -ge 350 ];        then atinew        else atiold        fi    fi}getInfo