summaryrefslogtreecommitdiffstats
path: root/initramfs/initrd-stuff/bin/xconfig
blob: 8865674c208fcc776de9189c550131f9c3a9d93f (plain) (blame)
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
224
225
226
227
228
229
230
231
232
233
234
235
#!/bin/sh
# Copyright (c) 2007 - RZ Uni Freiburg
# Copyright (c) 2007 - OpenSLX GmbH
#
# This program is free software distributed under the GPL version 2.
# See http://openslx.org/COPYING
#
# If you have any feedback please consult http://openslx.org/feedback and
# send your feedback to feedback@openslx.org
#
# General information about OpenSLX can be found under http://openslx.org
#
# Universal (distro independent) xorg.conf preparation script for OpenSLX 
# linux stateless clients, depending on ddcprobe

#############################################################################
# local functions used within - check if the monitor might be an older crt
iscrt () {
local dim=$1
local year=$2
local crt="CRT Generic"
# sub 17" displays
if [ $dim -lt 750 ] ; then
  # modern crt should have a size of 17"+
  if [ $year -gt 1998 ] ; then crt="TFT 4:3 <17inch" ; fi
# 17" crt displays, little bit smaller than tfts
elif [ $dim -lt 900 ] ; then
  crt="CRT 17inch"
  echo "1280x1024\n1152x864" > /tmp/res
# 19" crt / sub 19" tft
elif [ $dim -lt 1000 ] ; then
  if [ $year -lt 2001 ] ; then
    crt="CRT 19inch"
    echo "1400x1050\n1280x1024\n1152x864" > /tmp/res
  else
    crt="TFT 4:3 17inch"
  fi
# 18/19" tft displays (available after 2001)
elif [ $dim -lt 1200 ] ; then  
  if [ $year -ge 2002 ] ; then
    crt="TFT 4:3 18+inch"
  else
    crt="CRT 20inch"
    echo "1400x1050\n1280x1024\n1152x864" > /tmp/res
  fi
# sub 22" displays are crts if older than 2004 :)
elif [ $dim -lt 1300 ] ; then
  if [ $year -ge 2004 ] ; then
    crt="TFT 4:3 19+inch"
  else
    crt="CRT 20+inch"
    echo "1600x1200\n1400x1050\n1280x1024\n1152x864" > /tmp/res
  fi
# any bigger display is most probably a tft
elif [ $year -ge 2004 ] ; then
  crt="TFT 4:3 22+inch"
fi
echo "$crt"
}

#############################################################################
# main script

# functions common for all distros
. /etc/functions
# functions common for all distros, messages contains all error and
# info output
. /etc/messages
# load distro specific configuration variables and functions. distro
# specific functions may overwrite functions defined in /etc/functions
. /etc/sysconfig/config
. /etc/distro-functions

xfc="/tmp/xorg.conf"
echo "# ${D_XF86CONFFILE}" > $xfc
echo '
## autogenerated X hardware configuration by $0           ##
## OpenSLX.ORG Project <openslx-users@openslx.org>        ##
## DO NOT EDIT THIS FILE BUT '$0' INSTEAD                 ##
Section "Files"
EndSection
Section "ServerFlags"
  Option       "AllowMouseOpenFail"
  Option       "blank time"        "5"
  Option       "standby time"      "10"
  Option       "suspend time"      "15"
  Option       "off time"          "20"
EndSection
Section "Module"
  Load         "i2c"
  Load         "bitmap"
  Load         "ddc"
  Load         "extmod"
  Load         "freetype"
  Load         "int10"
  Load         "vbe"
  Load         "glx"
  Load         "dri"
EndSection
Section "InputDevice"
  Identifier "Generic Keyboard"
  Driver       "kbd"
  Option       "CoreKeyboard"
  Option       "XkbRules"          "xorg"
  Option       "XkbModel"          "pc105"
  Option       "XkbLayout"         "XKEYBOARD"
  Option       "XkbVariant"        "nodeadkeys"
EndSection
Section "InputDevice"
  Identifier   "Generic Mouse"
  Driver       "mouse"
  Option       "CorePointer"
  Option       "Device"            "/dev/input/mice"
  Option       "Protocol"          "ImPS/2"
  Option       "ZAxisMapping"      "4 5"
  Option       "Emulate3Buttons"   "true"
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "stylus"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "stylus"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "eraser"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "eraser"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "InputDevice"
  Driver       "wacom"
  Identifier   "cursor"
  Option       "Device"            "/dev/input/wacom"
  Option       "Type"              "cursor"
  Option       "ForceDevice"       "ISDV4"         # Tablet PC ONLY
EndSection
Section "Device"
  Identifier   "Generic Video Card"
  Driver       "vesa"
EndSection
Section "Monitor"
  Identifier   "Generic Display"
  Option       "DPMS"
EndSection
Section "Screen"
  Identifier   "Default Screen"
  Device       "Generic Video Card"
  Monitor      "Generic Display"
  DefaultDepth 24
  SubSection "Display"
    Depth        24
    Modes        "1024x768" "800x600"
  EndSubSection
EndSection
Section "ServerLayout"
  Identifier   "Default Layout"
  Screen       "Default Screen"
  InputDevice  "Generic Keyboard"
  InputDevice  "Generic Mouse"
  InputDevice  "stylus"            "SendCoreEvents"
  InputDevice  "cursor"            "SendCoreEvents"
  InputDevice  "eraser"            "SendCoreEvents"
EndSection
Section "DRI"
  Mode    0666
EndSection
'> $xfc

ddcprobe|sed "/mode: /d"|while read line ; do 
  case $line in
    ctiming*|dtiming*)
      Res=$(echo $line|sed "s/.*:\ //;s/@.*//")
      Width=${Res%%x*}
      Height=${Res##*x}
      # we need exact resolutions for tft displays only
      [ "${IsCrt%% *}" = "TFT" -a $((${Width}00 / ${Height})) -ge 125 ] && \
        echo $Res >> /tmp/res
      [ "x${VendorName}" = "x" ] && VendorName="No vendor string detected" 
        grep ModelName $xfc 2>&1 >/dev/null || \
          sed -e "/Section \"Monitor\"/a\ \ ModelName    \"Display - ${IsCrt}\"" \
              -e "/Section \"Device\"/a\ \ VendorName   \"${VendorName}\"" \
              -i $xfc	  
    ;;
    monitorname*|monitorid*)
      [ "x${line##monitor*:}" = "x" ] || sed "s/Display - /${line##monitor*: } - /" -i $xfc
    ;;
    product*)
      [ "$line" != "product:" ] && \
        sed "/Section \"Device\"/a\ \ BoardName    \"${line##product: }\"" \
          -i $xfc
    ;;
    oem*|vendor*)
      [ "x${line##?e*:}" = "x" ] || VendorName="${line##?e*: }"
    ;;
    manufacture*)
      Year=${line##* }
    ;;
    screensize*)
      Dim=${line##screensize: }
      Width=${Dim%% *}
      Height=${Dim##* }
      Dim=$(($Width * $Height))
      # check for geometry - no crt if no 4:3 ratio
      if [ $((${Width}00 / $((${Height} + 1 )))) -lt 140 ] ; then
        IsCrt="$(iscrt $Dim $Year)"
      else
        IsCrt="TFT WideScreen"
      fi
    ;;
  esac
done

# if predefined value is present otherwise use computed/detected stuff
if [ -n "${hw_monitor}" ] ; then
  # just cut all starting from k(Hz) ...
  #HS=${hw_monitor%k*}
  #VS=${hw_monitor%Hz*}
  Modes="\"${hw_monitor##* }\""
else
  for line in $(sort -run /tmp/res) ; do Modes="$Modes \"$line\""; done
fi
sed "s/Modes        \"/Modes       ${Modes} \"/" -i $xfc

# run localizator and configure X11 keyboard
localization "${country}"
if [ -z "${XKEYBOARD}" ] ; then
  error "${hcfg_keyb}" nonfatal
  XKEYBOARD="us"
fi
sed "s/XKEYBOARD/${XKEYBOARD}/" -i $xfc
# displayvars
#displayvars
#sed "/Section \"Device\"/a\ \ ${Files}" -i $xfc