Debian Codegraph @

site.example/local/sbin/dphys-config-x

raw
1 #!/bin/sh
2 # /usr/local/sbin/dphys-config-x - generate XFree server configuration
3 # author Neil Franklin, last modification 2006.10.13
4 # 2009.07.02 because of [ -a ] changed to ( [] && [] ), not tested after!!!
5 # copyright ETH Zuerich Physics Departement,
6 # use under either modified/non-advertising BSD or GPL license
7
8 # this script is called by dphys-config
9 # once on each config file or script install/update
10 # no parameters or environment variables are evaluated
11 # reads all input from config file /etc/dphys-config-x
12 # it requires in /etc/dphys-config.list 2 lines, for config file and script:
13 # dphys-config-x:/etc/:if [ -f /usr/local/sbin/dphys-config-x ] ; then /usr/local/sbin/dphys-config-x ; fi
14 # local/sbin/dphys-config-x:/usr/:chmod 755 {}; {}
15
16
17 ### ------ configuration for this site
18
19 # first CONF_* various site or user dependant user config variables
20 # then DEBUG_* various debugging settings
21 # last SYS_* various system internal values
22
23
24 # --- CONF_* various site or subnet dependant user config variables
25
26 # whether to generate XF86Config-4 (auto) or leave it alone (manual)
27 # defaults to manual, as user needs to make config file if something wanted
28 CONF_SETUP=manual
29
30 # what keyboard layout we have (us, en_US, de_CH, ...)
31 # defaults to international compatible standard here
32 CONF_KEYB_LAYOUT=us
33
34 # whether we have the extra 3 keys, and so need an keymap including them
35 # but enabling this screwd up xterm ALT key on Debian 3.0 (potato) XFree4.1
36 # and without they worked anyway, still does on Debian 3.1 (sarge) XFree4.3
37 # defaults to using the more universal setting
38 CONF_KEYB_EXTRA3=""
39
40 # where the PS/2 mouse is connected
41 # /dev/psaux (standard)
42 # /dev/misc/psaux (devfs)
43 # /dev/gmpdata (used for gpm)
44 # none (only USB mouse, disable PS/2 mouse, else keyboard dead)
45 # defaults to what we and most people use these days, now devfs is deprecated
46 CONF_PS2_MOUSE_DEV=/dev/psaux
47
48 # what PS/2 mouse type we have
49 # imps2 (Logitech Wheel Mouse)
50 # ps2 (2 or 3-button mouse)
51 # ps2scroll (Wheel Mouse with scrolling on button2 push)
52 # intelli (used for gpmdata)
53 # none (only USB mouse, disable PS/2 mouse, else keyboard dead)
54 # defaults to the most common mouse type around here
55 # fix it for old ps2, alternative ps2scroll or none
56 CONF_PS2_MOUSE_PROTO=imps2
57
58 # what USB mouse type we have
59 # imps2 (Logitech Wheel Mouse)
60 # ps2 (2 or 3-button mouse)
61 # ps2scroll (Wheel Mouse with scrolling on button2 push)
62 # intelli (used for gpmdata)
63 # none (only PS/2 mouse, disable USB mouse, don't load USB drivers)
64 # defaults to allow user to plug in anything, but this fails scroll wheels
65 #CONF_USB_MOUSE_PROTO=auto
66 # defaults to the most common mouse type around here
67 CONF_USB_MOUSE_PROTO=imps2
68
69 # what our monitor is capable of
70 # defaults to standard averge LCD abilities, as most are today LCDs
71 # old "CRT" and "LCD" settings were 121, "CRT-slow" and "EIZO-T68" had 96
72 CONF_HOR_MAX=121
73 # old "LCD" setting was 60, "CRT" and "CRT-slow" and "EIZO-T68" had 160
74 CONF_VER_MAX=60
75
76 # what physical size the monitor has, if not queryable, or overriding wanted
77 # format ist "xxx yyy" with xxx and yyy being size in mm
78 # defaults to nothing, as most systems here do not have it set
79 CONF_DISPSIZE=""
80
81 # force configuration for this device type
82 # defaults to using what lspci detects, change for special cases
83 CONF_DEVICE_TYPE=""
84
85 # PCI bus ID of what card we will be using, in cases it needs forcing
86 # defaults to nothing, as only needed on dual displays, and host specific
87 CONF_BUS_ID=""
88
89 # what amount of pixels we want
90 # such as 800x600, 1024x768, 1152x864, 1280x1024, 1400x1050, 1600x1200
91 # defaults to what most monitors are capable of displaying
92 CONF_RESOLUTION="1024x768"
93
94 # what amount of bits/pixel we want
95 # such as 1, 2, 4, 8, 15, 16, 24, 32
96 # defaults to what most cards can do and need
97 CONF_DEPTH=24
98
99 # whether we have an dual headed system or even Xinerama
100 # none (single screen)
101 # dual (2 screens separate, 2nd right of 1st)
102 # xine (2 screens merged, 2nd right of 1st)
103 CONF_DUAL=none
104
105 # log what we have done
106 CONF_LOG_DONE=yes
107
108
109 # --- DEBUG_*, various debugging settings
110
111 # force lots of debugging output
112 # this can also be enabled by touch /dphys-config-x.debug
113 #DEBUG_LOG_STEP=yes
114
115
116 # --- SYS_*, various system internal values
117
118 # what we are going to generate
119 SYS_X_CONFFILE=/etc/X11/XF86Config-4
120
121 # where we hope to find our X installation
122 SYS_X_PREFIX_PATH1=/usr/X11R64
123 SYS_X_PREFIX_PATH2=/usr/X11R6
124
125 # where we need to link the X server from and to
126 SYS_X_SERVER=bin/XFree86
127 SYS_X_LINK=/etc/X11/X
128
129 # settings for monitor resolutions, normal CRT monitor
130 # try stay inside ranges, so min slightly higher than normal standard VGA
131 SYS_HOR_MIN="32" # old was 30, may fail some monitors
132 SYS_VER_MIN="50" # old was 48, definitively failled some monitors
133
134
135
136 ### ------ actual implementation from here on
137 # no user settings any more below this point
138
139 set -e
140
141
142 # --- get ready to work
143
144 # sanitise this place, else some commands may fail
145 # must be before any commands are executed, incl config/input processing
146 # /usr/local added for FreeBSD, because their ports end up in there
147 PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
148 export PATH
149
150
151 # --- tidy up some commands, make systematic
152
153 # stuff that goes wrong, not expected by user, not in data output, use >&2
154 # so also with $0 in case this script was called by an other script
155 # something within the system that user does not expect, give up
156 CMD_FATAL="echo $0: FATAL:"
157 # something from users input, user will correct this and continue
158 CMD_ERROR="echo $0: ERROR:"
159 # something we can continue with, but may be wrong, and user may not suspect it
160 CMD_WARNING="echo $0: WARNING:"
161 # something most likely not wrong, but tell user for the odd case it is wrong
162 CMD_NOTE="echo $0: NOTE:"
163
164 # normal stuff users expect, so to stdout as normal output, no $0, no marking
165 CMD_INFO="echo"
166 # stuff users asked for, so add to stdout as normal output, no $0, but mark it
167 CMD_DEBUG="echo DEBUG:"
168
169
170 # and also put out some permanent messages, in case running as cron/init.d job
171 BASENAME="`basename $0`"
172 # stuff that goes wrong, not expected by user
173 # something within the system that user does not expect, give up
174 CMD_LOG_FATAL="logger -t ${BASENAME} -p user.error FATAL:"
175 # something from users input, user can possibly correct this and continue
176 CMD_LOG_ERROR="logger -t ${BASENAME} -p user.error ERROR:"
177 # something we can continue with, but may be wrong, and user may not suspect it
178 CMD_LOG_WARNING="logger -t ${BASENAME} -p user.warning WARNING:"
179 # something most likely not wrong, but tell user for the odd case it is wrong
180 CMD_LOG_NOTE="logger -t ${BASENAME} -p user.notice NOTE:"
181
182 # normal stuff users expect, so no marking
183 CMD_LOG_INFO="logger -t ${BASENAME} -p user.info"
184 # stuff users asked for, but mark it as special
185 CMD_LOG_DEBUG="logger -t ${BASENAME} -p user.debug DEBUG:"
186
187
188 # other stuff we may want to use
189 CMD_SLEEP="sleep 2"
190 CMD_WAIT="read -p ---DEBUG-wait-after-step--- dummy"
191
192
193 # --- config file stuff
194
195 # what we are
196 NAME=dphys-config-x
197 PNAME=dphys-config-x
198
199 # check user config file(s), let user override settings
200 if [ -e /etc/${PNAME} ] ; then
201 . /etc/${PNAME}
202 fi
203
204 # allow us to set logging despite no command line options and parser
205 if [ -f /${NAME}.debug ] ; then
206 DEBUG_LOG_STEP=yes
207 fi
208
209
210 # --- control variable output
211
212 # set config option controllable stuff
213 if [ x${CONF_LOG_DONE} = xyes ] ; then
214 CMD_LOG_IF_DONE="${CMD_LOG_INFO}"
215 else
216 CMD_LOG_IF_DONE=true
217 fi
218
219 # set debug option controllable stuff
220 if [ x${DEBUG_LOG_STEP} = xyes ] ; then
221 CMD_LOG_IF_DEBUG="${CMD_LOG_DEBUG}"
222 else
223 CMD_LOG_IF_DEBUG=true
224 fi
225
226
227 # show what config settings this debug run is using
228 ${CMD_LOG_IF_DEBUG} "CONF_SETUP=${CONF_SETUP}" \
229 "CONF_KEYB_LAYOUT=${CONF_KEYB_LAYOUT}" \
230 "CONF_KEYB_EXTRA3=${CONF_KEYB_EXTRA3}" \
231 "CONF_PS2_MOUSE_DEV=${CONF_PS2_MOUSE_DEV}" \
232 "CONF_PS2_MOUSE_PROTO=${CONF_PS2_MOUSE_PROTO}" \
233 "CONF_USB_MOUSE_PROTO=${CONF_USB_MOUSE_PROTO}" \
234 "CONF_HOR_MAX=${CONF_HOR_MAX}" \
235 "CONF_VER_MAX=${CONF_VER_MAX} CONF_DISPSIZE=${CONF_DISPSIZE}" \
236 "CONF_DEVICE_TYPE=${CONF_DEVICE_TYPE} CONF_BUS_ID=${CONF_BUS_ID}" \
237 "CONF_RESOLUTION=${CONF_RESOLUTION} CONF_DEPTH=${ONF_DEPTH}" \
238 "CONF_DUAL=${CONF_DUAL} CONF_LOG_DONE=${CONF_LOG_DONE}"
239
240
241 # --- test if we need to generate
242
243 if [ "${CONF_SETUP}" = manual ] ; then
244
245 ${CMD_NOTE} "no automatic X configuration selected for this host," \
246 "falling back to manual configuration file"
247 if [ -f "${SYS_X_CONFFILE}" ] ; then
248 exit 0
249 else
250 ${CMD_WARNING} "no configuration file at all," \
251 "continuing with making an automatic one, better than none" >&2
252 ${CMD_LOG_WARNING} "no configuration file at all," \
253 "continuing with making an automatic one, better than none"
254 CONF_SETUP=auto
255 fi
256
257 fi
258
259
260 # +++ temp stuff for while we are testing/migrating, delete it after +++
261
262 # eliminate old test file
263 if [ -f /etc/X11/XF86Config-4.test-dphys-config-x ] ; then
264 rm /etc/X11/XF86Config-4.test-dphys-config-x
265 fi
266
267 # backup old style working file in case new file fails to work
268 if [ ! -f /etc/X11/XF86Config-4.before-dphys-config-x ] ; then
269 if [ -f /etc/X11/XF86Config-4 ] ; then
270 mv /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.before-dphys-config-x
271 fi
272 fi
273
274 # prevent the old system from breaking the new file
275 if [ -x /etc/init.d/dphys-local-x ] ; then
276 chmod a-x /etc/init.d/dphys-local-x
277 fi
278 if [ -x /etc/init.d/dphys-setup-x ] ; then
279 chmod a-x /etc/init.d/dphys-setup-x
280 fi
281 if [ -x /etc/cron.daily/dphys-local-x ] ; then
282 chmod a-x /etc/cron.daily/dphys-local-x
283 fi
284 if [ -x /etc/cron.daily/dphys-setup-x ] ; then
285 chmod a-x /etc/cron.daily/dphys-setup-x
286 fi
287
288
289 # --- look for our X installation
290
291 X_PREFIX_PATH="${SYS_X_PREFIX_PATH1}"
292
293 if [ ! -d "${X_PREFIX_PATH}" ] ; then
294 X_PREFIX_PATH="${SYS_X_PREFIX_PATH2}"
295 fi
296
297 if [ ! -d "${X_PREFIX_PATH}" ] ; then
298 ${CMD_FATAL} "X installation can not be found, abborting ..." >&2
299 ${CMD_LOG_FATAL} "X installation can not be found, abborting ..."
300 exit 1
301 fi
302 ${CMD_LOG_IF_DEBUG} "X_PREFIX_PATH=${X_PREFIX_PATH}"
303
304 # and while here, fix up link to X server
305 if [ ! -L "${SYS_X_LINK}" ] ; then
306 if [ -e "${SYS_X_LINK}" ] ; then
307 ${CMD_FATAL} "${SYS_X_LINK} already being used for something else," \
308 "can not link to X server, abborting ..." >&2
309 ${CMD_LOG_FATAL} "${SYS_X_LINK} already being used for something else", \
310 "can not link to X server, abborting ..."
311 exit 1
312 fi
313 ln -s "${SYS_X_PREFIX_PATH2}/${SYS_X_SERVER}" "${SYS_X_LINK}"
314 fi
315
316
317 # --- make generic beginning section
318
319 cat > "${SYS_X_CONFFILE}" << END-CONFIG-FILE
320 # ${SYS_X_CONFFILE} - configure XFree X server for our hardware
321 # generator /usr/local/sbin/dphys-config-x, generated `date +%Y.%m.%d`
322
323 ### this file is automatically generated by dphys-config-x script
324 # change /etc/${PNAME} config file to define the parameters for this script
325 # parameters used for last run on this host were:
326 #
327 # CONF_SETUP=${CONF_SETUP}
328 # CONF_KEYB_LAYOUT=${CONF_KEYB_LAYOUT}
329 # CONF_KEYB_EXTRA3=${CONF_KEYB_EXTRA3}
330 # CONF_PS2_MOUSE_PROTO=${CONF_PS2_MOUSE_PROTO}
331 # CONF_PS2_MOUSE_DEV=${CONF_PS2_MOUSE_DEV}
332 # CONF_USB_MOUSE_DEV=${CONF_USB_MOUSE_DEV}
333 # CONF_HOR_MAX=${CONF_HOR_MAX}
334 # CONF_VER_MAX=${CONF_VER_MAX}
335 # CONF_DISPSIZE=${CONF_DISPSIZE}
336 # CONF_DEVICE_TYPE=${CONF_DEVICE_TYPE}
337 # CONF_BUS_ID=${CONF_BUS_ID}
338 # CONF_RESOLUTION=${CONF_RESOLUTION}
339 # CONF_DEPTH=${CONF_DEPTH}
340 # CONF_DUAL=${CONF_DUAL}
341
342
343 Section "Module"
344 END-CONFIG-FILE
345
346 if [ "${CONF_DEVICE_TYPE}" != nvidia ] ; then
347 # binary nvidia driver can not stand having GLcore loaded, has own GL
348 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
349 Load "GLcore"
350 END-CONFIG-FILE
351 fi
352
353 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
354 Load "bitmap"
355 Load "dbe"
356 Load "ddc"
357 Load "dri"
358 Load "extmod"
359 Load "freetype"
360 Load "glx"
361 Load "int10"
362 # Load "pex5" # deprecated
363 Load "record"
364 Load "speedo"
365 Load "type1"
366 Load "vbe"
367 # Load "xie" # deprecated
368 EndSection
369
370 Section "DRI"
371 Group "video"
372 Mode 0660
373 EndSection
374
375 Section "Files"
376 # these 2 variable because of self compiled X servers under woody
377 RgbPath "${X_PREFIX_PATH}/lib/X11/rgb"
378 ModulePath "${X_PREFIX_PATH}/lib/modules"
379 # FontPath "unix/:7100" # local font server
380 FontPath "/usr/X11R6/lib/X11/fonts/misc:unscaled"
381 FontPath "/usr/X11R6/lib/X11/fonts/cyrillic:unscaled"
382 FontPath "/usr/X11R6/lib/X11/fonts/100dpi:unscaled"
383 FontPath "/usr/X11R6/lib/X11/fonts/75dpi:unscaled"
384 FontPath "/usr/X11R6/lib/X11/fonts/Speedo"
385 FontPath "/usr/X11R6/lib/X11/fonts/TrueType"
386 FontPath "/usr/X11R6/lib/X11/fonts/misc"
387 FontPath "/usr/X11R6/lib/X11/fonts/cyrillic"
388 FontPath "/usr/X11R6/lib/X11/fonts/100dpi"
389 FontPath "/usr/X11R6/lib/X11/fonts/75dpi"
390 FontPath "/usr/X11R6/lib/X11/fonts/Type1"
391 EndSection
392
393 Section "ServerFlags"
394 Option "DontZoom" "true"
395 Option "AllowMouseOpenFail" "true"
396 EndSection
397 END-CONFIG-FILE
398
399
400 # --- make keyboard input section
401
402 if [ "${CONF_KEYB_EXTRA3}" = "" ] ; then
403
404 if [ "${CONF_KEYB_LAYOUT}" = us ] ; then
405 KEYB_KEYS=pc101
406 else
407 KEYB_KEYS=pc102
408 fi
409
410 else
411
412 if [ "${CONF_KEYB_LAYOUT}" = us ] ; then
413 KEYB_KEYS=pc104
414 else
415 KEYB_KEYS=pc105
416 fi
417
418 fi
419
420 ${CMD_LOG_IF_DEBUG} "KEYB_KEYS=${KEYB_KEYS}"
421
422
423 echo >> "${SYS_X_CONFFILE}"
424
425 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
426 Section "InputDevice"
427 Identifier "Keyboard0"
428 Driver "keyboard"
429 Option "XkbRules" "xfree86"
430 Option "XkbModel" "${KEYB_KEYS}"
431 Option "XkbLayout" "${CONF_KEYB_LAYOUT}"
432 EndSection
433 END-CONFIG-FILE
434
435
436 # --- make mouse input section
437
438 # - PS/2 mouse, if we have one
439
440 if ( [ "${CONF_PS2_MOUSE_DEV}" != none ] && \
441 [ "${CONF_PS2_MOUSE_PROTO}" != none ] ) ; then
442
443 if [ ! -e "${CONF_PS2_MOUSE_DEV}" ] ; then
444 ${CMD_ERROR} "non existant PS/2 mouse device" \
445 "\"${CONF_PS2_MOUSE_DEV}\", abborting ..." >&2
446 ${CMD_LOG_ERROR} "non existant PS/2 mouse device" \
447 "\"${CONF_PS2_MOUSE_DEV}\", abborting ..."
448 exit 1
449 fi
450
451 echo >> "${SYS_X_CONFFILE}"
452
453 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
454 Section "InputDevice"
455 Identifier "MousePS20"
456 Driver "mouse"
457 Option "Device" "${CONF_PS2_MOUSE_DEV}"
458 END-CONFIG-FILE
459
460 if [ "${CONF_PS2_MOUSE_PROTO}" = imps2 ] ; then
461 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
462 Option "Protocol" "ImPS/2"
463 Option "ZAxisMapping" "4 5"
464 END-CONFIG-FILE
465 elif [ "${CONF_PS2_MOUSE_PROTO}" = ps2 ] ; then
466 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
467 Option "Protocol" "PS/2"
468 END-CONFIG-FILE
469 elif [ "${CONF_PS2_MOUSE_PROTO}" = ps2scroll ] ; then
470 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
471 Option "Protocol" "PS/2"
472 Option "Emulate3Buttons" "on"
473 Option "Emulate3Timeout" "50"
474 Option "EmulateWheel" "on"
475 Option "EmulateWheelButton" "2"
476 END-CONFIG-FILE
477 elif [ "${CONF_PS2_MOUSE_PROTO}" = intelli ] ; then
478 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
479 Option "Protocol" "IntelliMouse"
480 Option "ZAxisMapping" "4 5"
481 END-CONFIG-FILE
482 else
483 ${CMD_ERROR} "unknown PS/2 mouse protocol" \
484 "\"${CONF_PS2_MOUSE_PROTO}\", abborting ..." >&2
485 ${CMD_LOG_ERROR} "unknown PS/2 mouse protocol" \
486 "\"${CONF_PS2_MOUSE_PROTO}\", abborting ..."
487 exit 1
488 fi
489
490 echo EndSection >> "${SYS_X_CONFFILE}"
491
492 fi
493
494
495 # - USB mouse, if we want to allow one
496
497 if [ "${CONF_USB_MOUSE_PROTO}" != none ] ; then
498
499 # while here, install and load kernel modules needed for USB mouse
500 # usbcore is needed for all USB stuff, should be already in, but go safe
501 # input is general infrastructure, basic key/mouse/etc stuff
502 # hid and usbhid are generic 2.4 and 2.6 USB HID key/mouse/etc protocol
503 # mousedev basic input->mouse device
504 for MODULE in usbcore input hid usbhid mousedev ; do
505 # insert them into /etc/modules for after future boots
506 grep ${MODULE} /etc/modules > /dev/null || echo ${MODULE} >> /etc/modules
507 # insert them into the running kernel for this session
508 # use || true so we can try nonexist other kernel version modules
509 # else set -e will nuke this script when we try this
510 grep "^${MODULE}" /proc/modules > /dev/null || \
511 modprobe ${MODULE} 2> /dev/null || true
512 done
513
514 # and while here, fix up device node for USB mouse
515 if [ ! -c /dev/input/mice ]; then
516 if [ -e /dev/input/mice ]; then
517 ${CMD_FATAL} "/dev/input/mice is already being used for something" \
518 "else, can not make node for USB mouse, abborting ..." >&2
519 ${CMD_LOG_FATAL} "/dev/input/mice is already being used for something" \
520 "else, can not make node for USB mouse, abborting ..."
521 exit 1
522 fi
523 mkdir -p /dev/input
524 mknod /dev/input/mice c 13 63
525 fi
526
527 echo >> "${SYS_X_CONFFILE}"
528
529 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
530 Section "InputDevice"
531 Identifier "MouseUSB0"
532 Driver "mouse"
533 Option "Device" "/dev/input/mice"
534 END-CONFIG-FILE
535
536 if [ "${CONF_USB_MOUSE_PROTO}" = imps2 ] ; then
537 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
538 Option "Protocol" "ImPS/2"
539 Option "ZAxisMapping" "4 5"
540 END-CONFIG-FILE
541 elif [ "${CONF_USB_MOUSE_PROTO}" = ps2 ] ; then
542 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
543 Option "Protocol" "PS/2"
544 END-CONFIG-FILE
545 elif [ "${CONF_USB_MOUSE_PROTO}" = ps2scroll ] ; then
546 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
547 Option "Protocol" "PS/2"
548 Option "Emulate3Buttons" "on"
549 Option "Emulate3Timeout" "50"
550 Option "EmulateWheel" "on"
551 Option "EmulateWheelButton" "2"
552 END-CONFIG-FILE
553 else
554 ${CMD_ERROR} "unknown USB mouse protocol" \
555 "\"${CONF_USB_MOUSE_PROTO}\", abborting ..." >&2
556 ${CMD_LOG_ERROR} "unknown USB mouse protocol" \
557 "\"${CONF_USB_MOUSE_PROTO}\", abborting ..."
558 exit 1
559 fi
560
561 echo EndSection >> "${SYS_X_CONFFILE}"
562
563 fi
564
565
566 # --- make monitor info section
567
568 ${CMD_LOG_IF_DEBUG} "SYS_HOR_MIN=${SYS_HOR_MIN} CONF_HOR_MAX=${CONF_HOR_MAX}" \
569 "SYS_VER_MIN=${SYS_VER_MIN} CONF_VER_MAX=${CONF_VER_MAX}"
570
571
572 echo >> "${SYS_X_CONFFILE}"
573
574 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
575 Section "Monitor"
576 Identifier "Monitor0"
577 HorizSync ${SYS_HOR_MIN} - ${CONF_HOR_MAX}
578 VertRefresh ${SYS_VER_MIN} - ${CONF_VER_MAX}
579 Option "DPMS"
580 END-CONFIG-FILE
581
582 if [ "`echo "${CONF_DISPSIZE}" | tr -d ' '`" != "" ] ; then
583 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
584 DisplaySize ${CONF_DISPSIZE}
585 END-CONFIG-FILE
586 fi
587
588 echo EndSection >> "${SYS_X_CONFFILE}"
589
590
591 if [ "${CONF_DUAL}" != none ] ; then
592 # duplicate the monitor section, with 0 -> 1
593 echo >> "${SYS_X_CONFFILE}"
594 sed -ne '/Section "Monitor"/,/EndSection/p' "${SYS_X_CONFFILE}" | \
595 sed -e 's/Monitor0/Monitor1/' > "${SYS_X_CONFFILE}.mon1"
596 cat "${SYS_X_CONFFILE}.mon1" >> "${SYS_X_CONFFILE}"
597 rm "${SYS_X_CONFFILE}.mon1"
598 fi
599
600
601 # --- make device settings section
602
603 # auto-identify what card we have, from PCI ID
604 PCI_ID="`lspci -n | sed 's/Class //' | \
605 awk '$2=="0300:"||$2=="0380:" { print $3 }' | head -1`"
606 # translate to our internal device/card/parameter-set name
607 # get rid of comments and empty lines (may be emptied comment lines)
608 DEVICE_TYPE="`cut -f 1 -d '#' << END-PCI_ID-LIST | \
609 grep -v '^ *$' | grep "^${PCI_ID}" | awk '{ print $2 }'
610 1002:4750 ati # ATI 3D Rage Pro 215GP
611 1002:4752 ati # ATI Rage XL
612 1002:4756 ati # ATI 3D Rage IIC 215IIC [Mach64 GT IIC]
613 1002:4c57 radeon # ATI Radeon Mobility M7 LW [Radeon Mobility 7500]
614 1002:4c66 radeon # ATI Radeon R250 Lf [Radeon Mobility 9000 M9]
615 1002:5046 ati # ATI Rage 128 PF/PRO AGP 4x TMDS
616 1002:5159 radeon # ATI Radeon RV100 QY [Radeon 7000/VE]
617 1002:5246 ati # ATI Rage 128 RF/SG AGP
618 1002:5940 fglrx # ATI RV280 [Radeon 9200 PRO] (Secondary)
619 1002:5960 fglrx # ATI RV280 [Radeon 9200 PRO]
620 1014:0170 vesa # IBM GXT6000P Graphics Adapter
621 102b:0519 mga # Matrox MGA 2064W [Millennium]
622 102b:051b mga # Matrox MGA 2164W [Millennium II]
623 102b:0520 mga # Matrox MGA G200
624 102b:0521 mga # Matrox MGA G200 AGP
625 102b:0525 mga # Matrox MGA G400 AGP
626 102b:2527 mga # Matrox MGA G550 AGP
627 104c:3d07 ti # TI TVP4020 [Permedia 2]
628 10de:0110 nv # nVidia NV11 [GeForce2 MX/MX 400]
629 10de:0161 nvidia # nVidia NV44 [GeForce 6200 TurboCache(TM)]
630 10de:0175 nv # nVidia NV17 [GeForce4 420 Go] (Toshiba)
631 10de:01f0 nv # nVidia NV18 [GeForce4 MX - nForce GPU] (Shuttle on-board)
632 10de:0322 nvidia # nVidia NV34 [GeForce FX 5200]
633 10de:0393 nvidia # nVidia G70 [GeForce 7300 GT]
634 15ad:0405 vmware # VMware [VMWare SVGA II] PCI Display Adapter
635 5333:8811 s3 # S3 86c764/765 [Trio32/64/64V+]
636 8086:1132 i810 # Intel 82815 CGC [Chipset Graphics Controller] (i810)
637 8086:2562 i810 # Intel 82845G/GL[Brookdale-G]/GE Chipset I G D (i810)
638 #8086:2582 i810 # Intel 82915G Graphics Controller (rev 04)
639 8086:2582 vesa # Intel 82915G Graphics Controller (rev 04)
640 END-PCI_ID-LIST`"
641
642 if [ "${CONF_DEVICE_TYPE}" != "" ] ; then
643 # allow config to force an device type, for unknown or exeptional cases
644 # used to manually force usage of binary drivers, never automatic
645 DEVICE_TYPE="${CONF_DEVICE_TYPE}"
646 fi
647
648 if [ "${DEVICE_TYPE}" = "" ] ; then
649 ${CMD_WARNING} "unknown video card PCI ID ${PCI_ID}," \
650 "falling back to vesa mode ..." >&2
651 ${CMD_LOG_WARNING} "unknown video card PCI ID ${PCI_ID}," \
652 "falling back to vesa mode ..."
653 DEVICE_TYPE=vesa
654 fi
655
656 ${CMD_LOG_IF_DEBUG} "DEVICE_TYPE=${DEVICE_TYPE}"
657
658
659 echo >> "${SYS_X_CONFFILE}"
660
661 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
662 Section "Device"
663 Identifier "Device0"
664 END-CONFIG-FILE
665
666 if [ "${DEVICE_TYPE}" = ati ] ; then
667 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
668 Driver "ati"
669 VendorName "ATI"
670 BoardName "ATI Rage"
671 END-CONFIG-FILE
672 elif [ "${DEVICE_TYPE}" = fglrx ] ; then
673 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
674 Driver "fglrx"
675 VendorName "ATI"
676 BoardName "ATI Radeon Closed Binary"
677 END-CONFIG-FILE
678 elif [ "${DEVICE_TYPE}" = i810 ] ; then
679 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
680 Driver "i810"
681 VendorName "Intel"
682 BoardName "OnBoard i810"
683 VideoRam 16384
684 Option "XvMCSurfaces" "6"
685 Option "AGPMode" "1"
686 END-CONFIG-FILE
687 elif [ "${DEVICE_TYPE}" = mga ] ; then
688 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
689 Driver "mga"
690 VendorName "Matrox"
691 BoardName "MGA"
692 Option "OverclockMem" "true"
693 Option "Overlay" "true"
694 END-CONFIG-FILE
695 elif [ "${DEVICE_TYPE}" = nv ] ; then
696 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
697 Driver "nv"
698 VendorName "nVidia"
699 BoardName "nVidia Free"
700 END-CONFIG-FILE
701 elif [ "${DEVICE_TYPE}" = nvidia ] ; then
702 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
703 Driver "nvidia"
704 VendorName "nVidia"
705 BoardName "nVidia Closed Binary"
706 END-CONFIG-FILE
707 elif [ "${DEVICE_TYPE}" = radeon ] ; then
708 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
709 Driver "radeon"
710 VendorName "ATI"
711 BoardName "ATI Radeon Free"
712 END-CONFIG-FILE
713 elif [ "${DEVICE_TYPE}" = s3 ] ; then
714 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
715 Driver "s3"
716 VendorName "S3"
717 BoardName "Trio32/64"
718 END-CONFIG-FILE
719 elif [ "${DEVICE_TYPE}" = ti ] ; then
720 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
721 Driver "glint"
722 VendorName "Texas Instruments"
723 BoardName "Permedia 2"
724 END-CONFIG-FILE
725 elif [ "${DEVICE_TYPE}" = vesa ] ; then
726 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
727 Driver "vesa"
728 VendorName "Unknown"
729 BoardName "Unknown using VESA"
730 END-CONFIG-FILE
731 elif [ "${DEVICE_TYPE}" = vmware ] ; then
732 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
733 Driver "vmware"
734 VendorName "VMware"
735 BoardName "VMware"
736 # see vmware(4)
737 #Option "HWcursor" "false"
738 #Option "NoAccel" "false"
739 END-CONFIG-FILE
740 else
741 ${CMD_FATAL} "unknown device type \"${DEVICE_TYPE}\", abborting ..." >&2
742 ${CMD_LOG_FATAL} "unknown device type \"${DEVICE_TYPE}\", abborting ..."
743 exit 1
744 fi
745
746 for TEST_DEVICE in ati fglrx i810 mga nv nvidia nvidia-free radeon s3 ti ; do
747 if [ "${DEVICE_TYPE}" = ${TEST_DEVICE} ] ; then
748 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
749 Option "SWcursor" "true"
750 Option "HWcursor" "false"
751 Option "DPMS" "true"
752 END-CONFIG-FILE
753 fi
754 done
755
756 if [ "${CONF_BUS_ID}" != "" ] ; then
757 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
758 BusID "${CONF_BUS_ID}"
759 END-CONFIG-FILE
760 fi
761
762 if [ "${CONF_DUAL}" != none ] ; then
763 if [ "${CONF_BUS_ID}" = "" ] ; then
764 ${CMD_ERROR} "dualhead display selected but no CONF_BusID given," \
765 "abborting ..." >&2
766 ${CMD_LOG_ERROR} "dualhead display selected but no CONF_BusID given," \
767 "abborting ..."
768 exit 1
769 fi
770 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
771 Screen 0
772 END-CONFIG-FILE
773 fi
774
775 echo EndSection >> "${SYS_X_CONFFILE}"
776
777
778 if [ "${CONF_DUAL}" != none ] ; then
779 # duplicate the device section, with 0 -> 1
780 echo >> "${SYS_X_CONFFILE}"
781 sed -ne '/Section "Device"/,/EndSection/p' "${SYS_X_CONFFILE}" | \
782 sed -e 's/Device0/Device1/' | \
783 sed -e '/Screen/s/0/1/' > "${SYS_X_CONFFILE}.dev1"
784 cat "${SYS_X_CONFFILE}.dev1" >> "${SYS_X_CONFFILE}"
785 rm "${SYS_X_CONFFILE}.dev1"
786 fi
787
788
789 # --- make screen settings section
790
791 if [ "${CONF_RESOLUTION}" = "" ] ; then
792 CONF_RESOLUTION=1024x768
793 fi
794 if [ "${CONF_DEPTH}" = "" ] ; then
795 CONF_DEPTH=24
796 fi
797
798 for TEST_DEVICE in fglrx mga nv nvidia radeon s3 ti ; do
799 if [ "${DEVICE_TYPE}" = ${TEST_DEVICE} ] ; then
800 NEED_FB32=true
801 fi
802 done
803
804 ${CMD_LOG_IF_DEBUG} "CONF_RESOLUTION=${CONF_RESOLUTION}" \
805 "CONF_DEPTH=${CONF_DEPTH} NEED_FB32=${NEED_FB32}"
806
807
808 echo >> "${SYS_X_CONFFILE}"
809
810 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
811 Section "Screen"
812 Identifier "Screen0"
813 Device "Device0"
814 Monitor "Monitor0"
815 DefaultDepth ${CONF_DEPTH}
816 END-CONFIG-FILE
817
818 if [ "${NEED_FB32}" != "" ] ; then
819 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
820 DefaultFbBpp 32
821 END-CONFIG-FILE
822 fi
823
824 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
825 SubSection "Display"
826 Depth ${CONF_DEPTH}
827 Modes "${CONF_RESOLUTION}"
828 EndSubSection
829 EndSection
830 END-CONFIG-FILE
831
832
833 if [ "${CONF_DUAL}" != none ] ; then
834 # duplicate the screen section, with 0 -> 1
835 echo >> "${SYS_X_CONFFILE}"
836 sed -ne '/Section "Screen"/,/EndSection/p' "${SYS_X_CONFFILE}" | \
837 sed -e 's/Screen0/Screen1/' | \
838 sed -e 's/Device0/Device1/' | \
839 sed -e 's/Monitor0/Monitor1/' > "${SYS_X_CONFFILE}.dev1"
840 cat "${SYS_X_CONFFILE}.dev1" >> "${SYS_X_CONFFILE}"
841 rm "${SYS_X_CONFFILE}.dev1"
842 fi
843
844
845 # --- make ending section
846
847 echo >> "${SYS_X_CONFFILE}"
848
849 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
850 Section "ServerLayout"
851 Identifier "XFree86 by dphys-config-x"
852 Screen 0 "Screen0" 0 0
853 END-CONFIG-FILE
854
855 if [ "${CONF_DUAL}" != none ] ; then
856 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
857 Screen 1 "Screen1" RightOf "Screen0"
858 END-CONFIG-FILE
859 fi
860
861 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
862 InputDevice "Keyboard0" "CoreKeyboard"
863 END-CONFIG-FILE
864
865 # on some systems enabling PS/2 mouse with only an USB mouse connected
866 # crashes the PS/2 controller, so losing PS/2 keyboard access
867 if ( [ "${CONF_PS2_MOUSE_DEV}" != none ] && \
868 [ "${CONF_PS2_MOUSE_PROTO}" != none ] ) ; then
869 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
870 InputDevice "MousePS20" "CorePointer"
871 END-CONFIG-FILE
872 # max be no USB mouse, that is allowed if PS/2
873 if [ "${CONF_USB_MOUSE_PROTO}" != none ] ; then
874 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
875 InputDevice "MouseUSB0" "SendCoreEvents"
876 END-CONFIG-FILE
877 fi
878 else
879 # if no PS/2 then no USB is most likely wrong, complain but continue
880 if [ "${CONF_USB_MOUSE_PROTO}" != none ] ; then
881 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
882 InputDevice "MouseUSB0" "CorePointer"
883 END-CONFIG-FILE
884 else
885 ${CMD_WARNING} "no mouse chosen at all, both PS/2 and USB set to none" >&2
886 ${CMD_LOG_WARNING} "no mouse chosen at all, both PS/2 and USB set to none"
887 fi
888 fi
889
890 if [ "${CONF_DUAL}" = xine ] ; then
891 cat >> "${SYS_X_CONFFILE}" << END-CONFIG-FILE
892 Option "Xinerama" "on"
893 END-CONFIG-FILE
894 fi
895
896 echo EndSection >> "${SYS_X_CONFFILE}"
897
898
899 # --- finish off
900
901 ${CMD_LOG_IF_DONE} "has generated/replaced ${SYS_X_CONFFILE}"
902 exit 0