summaryrefslogtreecommitdiffstats
path: root/abs/core/LinHES-config/xconfig.sh
blob: 702456608013fd56fc4ef023c0191626e2522353 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/bin/bash
#set -x
#SET DISPLAYRES to force Xres, ENV takes precendent over cmdline


LOGFILE=/tmp/xconfig.log
for i in ati intel mga savage sis unichrome
do
    templist=`echo $i-dri xf86-video-$i`
    NVPKGS=`echo $NVPKGS  $templist`

done
BASE=""
MYTH_RUN_STATUS="1"
. /etc/profile

MYTHHOME=$BASE/home/mythtv

function Xvalues {
    CMDLINE=$(cat /proc/cmdline)
    echo "$CMDLINE" | grep -q forceXvesa
    if [ $? = 0  ]
    then
        echo "Forcing driver to vesa"
        VGACARDTYPE=vesa
        Xcardtype=$VGACARDTYPE
    else
        VGACARDTYPE=`lspci | grep -i vga | sort -r | head -n 1 | cut -d: -f3 | cut -d" " -f2`
        VGAPCIID=`lspci | grep -i vga | sort -r | head -n 1 | cut -d" " -f1`
        CARDID=`lspci -n | grep "$VGAPCIID" | grep 10de | cut -d" " -f3 | cut -d: -f2`
        VENDORID=`lspci -n | grep "$VGAPCIID" | grep 10de | cut -d" " -f3 | cut -d: -f1`
    fi
    echo "Detected $VGACARDTYPE as the video card type"
}

function presetupX {

    if  [ "$XIgnoreConfig" = 1 ]
    then
        echo "Using User supplied X"
        if [ -f "$MYTHHOME/templates/xorg.user" ]
        then
            cp -f "$MYTHHOME/templates/xorg.user" "$XORG_CONF"
        else
            echo "Didn't find the file"
            echo "Copy your config file to $MYTHHOME/templates/xorg.user" > "$XORG_CONF"
        fi
    else
        setupX
    fi


}

function nvidia_prepare {
    for i in libgl nvidia nvidia-utils nvidia-173xx nvidia-173xx-utils nvidia-96xx nvidia-96xx-utils
    do
        pacman --noconfirm -Rdd $i >> $LOGFILE 2>&1
    done

    for i in `echo ${NVPKGS}`
    do
        pacman --noconfirm  -Rc $i >> $LOGFILE 2>&1
    done


}

function pkg_check () {
    echo "  Checking for $1 in cache or online"
    pacman --noconfirm -Sw $1 >> $LOGFILE 2>&1
    rc=$?
    if [ $rc != 0 ]
    then
        echo "  Couldn't find $1 for install, aborting"
        echo "  Couldn't find $1 for install, aborting" >> $LOGFILE 2>&1
        exit 1
    fi



    }

function nvidia_driver_install {

    cp "$TEMPLATES/xorg/xorg.conf.nvidia"  $BASE/etc/X11/xorg.conf.d/20-automv.conf
    #grep -qi "$CARDID" "$NVIDIA_SUPPORTED"

    #if [ $? = 0 ]
    #then
        #install latest drivers
        pkg_check nvidia-utils
        echo "Installing current nvidia drivers"
        nvidia_prepare
        pacman --noconfirm  -S nvidia nvidia-utils >> $LOGFILE 2>&1
        installed=1
    #fi

    if [ \"$Xres\" = "Auto" ]
    then
        nvidia-xconfig -c /etc/X11/xorg.conf.d/20-automv.conf --mode-list="nvidia-auto-select"
    else
        #nvidia-xconfig -c /etc/X11/xorg.conf.d/20-automv.conf --mode-list=$Xres
        eval nvidia-xconfig -c /etc/X11/xorg.conf.d/20-automv.conf --mode-list=\"${Xres}\"
    fi

    echo "/usr/lib/libXvMCNVIDIA_dynamic.so.1" > "$XVMC_CONFIG"
}

# if [ "$Xcategory" = "Nvidia" ]
# then
# #Xres=""
# if [ "$XnVidia1080p" = "1" ]
# then
# Xres="${Xres} 1920x1080_60"
# fi
# if [ "$XnVidia1080i" = "1" ]
# then
# Xres="${Xres} 1920x1080_60i"
# fi
# if [ "$XnVidia720p" = "1" ]
# then
# Xres="${Xres} 1280x720_60"
# fi
# if [ "$XnVidia480p" = "1" ]
# then
# Xres="${Xres} 720x480_60"
# fi



function setupX {
    Xvalues
    if [ x = x ]
    then
        case $VGACARDTYPE in
            NVIDIA|nVidia|nvidia)
                    nvidia_driver_install
                ;;

            VMware)
                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.vmware" > "$XORG_CONF"
                    ;;

            Intel|intel)
               if [ ${Xres} = Auto ]
                then
                    sed -e "/^.*Modes.*$/d" "$TEMPLATES/xorg/xorg.conf.intel" > "$XORG_CONF"
                else
                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.intel" > "$XORG_CONF"
                fi
                if [ "$TESTMODE" != "test" ]
                then
                    pacman --noconfirm -R nvidia-utils >> $LOGFILE 2>&1
                    pacman --noconfirm -S libgl >> $LOGFILE 2>&1
                fi
                echo "/usr/lib/libIntelXvMC.so.1" > "$XVMC_CONFIG"
                ;;

            vesa|InnoTek|*)
                echo "Using the vesa driver"
                if [ ${Xres} = Auto ]
                then
                    sed -e "/^.*Modes.*$/d" "$TEMPLATES/xorg/xorg.conf.vesa" > "$XORG_CONF"
                else
                    sed -e "s/^.*Modes.*$/\t Modes \"${Xres}\"/" "$TEMPLATES/xorg/xorg.conf.vesa" > "$XORG_CONF"
                fi
                ;;

        esac
    fi

}


#---------------------------------------------------------------------------------
#MAIN


LINE=`grep -i xorg /etc/mythvantage.cfg|grep -q False`
rc=$?
if  [ $rc = 0 ]
then
    echo "**   xorg configuration disabled in /etc/mythvantage.cfg"
    exit 1
fi

if [ -f /etc/sysconfig/IGNORE_X ]
then
    echo "**   Will not run xconfig.sh due to presence of /etc/sysconfig/IGNORE_X"
    exit 1
fi



if [ -f /etc/systemconfig ]
then
    . /etc/systemconfig
else
    Xres="800x600"
fi
CMDLINE=$(cat /proc/cmdline)
echo $CMDLINE | grep -q displayres
if [ $? = 0 ]
then
    TEMPVAR=${CMDLINE#*displayres=}
    DSR=${TEMPVAR%% *}
fi
if [ ! x$DSR = x ]
then
    Xres=$DSR
fi
if [ ! x$DISPLAYRES = x ]
then
    Xres=$DISPLAYRES
fi



XORG_CONF="/etc/X11/xorg.conf"
XVMC_CONFIG="/etc/X11/XvMCConfig"

presetupX