Enable xmode bootparameter
[grml-x.git] / grml-x
1 #!/bin/zsh
2 # Filename:      grml-x
3 # Purpose:       wrapper for startx on grml [providing new xconfiguration tool]
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 # Latest change: Sam Jän 20 10:42:37 CET 2007 [mika]
8 ################################################################################
9
10 # some zsh-stuff {{{
11   if [[ $DEBUG -gt 0 ]]; then
12       setopt xtrace
13   fi
14   autoload colors ; colors
15   [ -r /etc/grml_colors ] && . /etc/grml_colors
16   [ -r /etc/grml/sh-lib ] && . /etc/grml/sh-lib
17   if [ -r /etc/sysconfig/keyboard ] ; then
18     source /etc/sysconfig/keyboard
19   else
20     XKEYBOARD='us'
21   fi
22 # }}}
23
24 # warn if running as user root {{{
25   if [[ $UID == 0 ]] ; then
26      print "$bg[black]$fg[red]${bold_color}Warning: Please do not run grml-x as user root.${reset_color}"
27      print "$bg[black]$fg[red]${bold_color}Running grml-x as user root is *not* supported!${reset_color}"
28      print "$bg[black]$fg[red]${bold_color}Switch to user grml or run su - grml -c 'grml-x ...' instead.${reset_color}"
29      # exit -1
30   fi
31   fstabuser=$(grep ':x:1000:' /etc/passwd)
32   export fstabuser=${fstabuser%%[:]*}
33 # }}}
34
35 # set variables  {{{
36   PROGRAMNAME=${0##*/}
37   HWINFO='/usr/sbin/hwinfo'
38   DATE=$(date)
39   (( ${+XINITRC} )) || XINITRC="$HOME/.xinitrc"
40 # }}}
41
42 # usage information {{{
43 usage()
44 {
45   if [[ $1 != '' ]] ; then echo 1>&2 "\n$1" ; fi
46   print "$bg[black]$fg[red]$bold_color"
47   print 1>&2 "
48 Usage: $PROGRAMNAME
49        $PROGRAMNAME [-options] windowmanager
50
51 Examples:
52   $PROGRAMNAME wmii
53   $PROGRAMNAME pekwm
54   $PROGRAMNAME fluxbox
55   $PROGRAMNAME -force -nostart fluxbox
56   $PROGRAMNAME -nosynaptics fluxbox
57   $PROGRAMNAME -nosync fluxbox
58   $PROGRAMNAME -noddc wmii
59   $PROGRAMNAME -nousb fluxbox
60   $PROGRAMNAME -module radeon -mode 1024x768 -vsync 60 wmi
61   XINITRC=~/.xinitrc $PROGRAMNAME ion
62   $PROGRAMNAME -display 8 wmii
63
64 More information on grml-x can be found in the manual page: man grml-x
65
66 Report bugs, send wishes and feedback to the grml team:
67 http://grml.org/bugs/ - contact (at) grml.org
68 "
69 #  $PROGRAMNAME wmi -- :8
70   print "${reset_color}"
71   exit 2
72 }
73 # }}}
74
75 # writehwinfo {{{
76 writehwinfo()
77 {
78    HWINFO_TMP="/tmp/hwinfo.$$"
79    if [[ $UID == 0 ]] ; then
80      su - $fstabuser -c "$HWINFO > $HWINFO_TMP"
81    else
82      $HWINFO > $HWINFO_TMP
83    fi
84 }
85 # }}}
86
87 # monitor {{{
88 monitor()
89 {
90   MONITORINFO="/tmp/monitorinfo.$$"
91   sudo $HWINFO --monitor > $MONITORINFO
92 }
93 # }}}
94
95 # mode {{{
96 mode()
97 {
98    modes=$(perl -e 'while (<STDIN>) {if (/  Resolution:/) { s/.*\s+(\d+x\d+).*/$1/; print} }' < $MONITORINFO |
99 sort -nur | perl -ne 's/\s+/ /; s/(\d+x\d+)/"$1"/; print')
100    if [[ -n $NODDC ]] ; then
101      MODES='Modes "1024x768" "800x600" "640x480"  "1600x1200" "1280x1024" "1280x960"'
102    elif [[ "$modes" == "\"1024x768\" " || -z $modes ]] ; then
103      MODES='# Modes "1024x768" "800x600" "640x480"  "1600x1200" "1280x1024" "1280x960"'
104    else
105      MODES="# Modes $modes"
106    fi
107 }
108 # }}}
109
110 # sync - get hsync/vsync settings {{{
111 sync()
112 {
113    monitor # get monitor settings
114    vsyncval=$(awk '/Vert. Sync Range:/{print $4}' $MONITORINFO | sed 's/-/.0 - / ; s/$/.0/' | head -1)
115    hsyncval=$(awk '/Hor. Sync Range:/{print $4}'  $MONITORINFO | sed 's/-/.0 - / ; s/$/.0/' | head -1)
116    if [ -z $vsyncval ] ; then
117      vsyncval='50.0 - 60.0'
118    fi
119    if [ -z $hsyncval ] ; then
120      hsyncval='28.0 - 96.0'
121    fi
122 }
123 sync
124 # }}}
125
126 # mouse {{{
127 mouse()
128 {
129    MOUSEINFO="/tmp/mouse.$$"
130 #   if [[ $UID == 0 ]] ; then
131 #     su - $fstabuser -c "$HWINFO --mouse > $MOUSEINFO"
132 #   else
133      sudo $HWINFO --mouse > $MOUSEINFO
134 #   fi
135
136    # SynPS/2 Synaptics TouchPad
137    if grep -q 'Device:.*Synaptics' "$MOUSEINFO" ; then
138     if [[ "$SYNAPTICS" == "yes" ]] ; then # check for '-nosynaptics'-option
139      MOUSEDRIVER='synaptics'
140      # SYNMOUSE='InputDevice    "Synaptics" "CorePointer"'
141      SYNMOUSE='InputDevice    "Synaptics"  "AlwaysCore"'
142      SYNMOUSEDETAIL="
143 Section \"InputDevice\"
144   Driver        \"synaptics\"
145   Identifier    \"Synaptics\"
146   Option        \"Device\"        \"/dev/psaux\"
147   Option        \"Protocol\"      \"auto-dev\"
148   Option        \"LeftEdge\"      \"1700\"
149   Option        \"RightEdge\"     \"5300\"
150   Option        \"TopEdge\"       \"1700\"
151   Option        \"BottomEdge\"    \"4200\"
152   Option        \"FingerLow\"     \"25\"
153   Option        \"FingerHigh\"    \"30\"
154   Option        \"ZAxisMapping\"   \"4 5\"
155   Option        \"MaxTapTime\"    \"180\"
156   Option        \"MaxTapMove\"    \"220\"
157   Option        \"VertScrollDelta\" \"100\"
158   Option        \"MinSpeed\"      \"0.06\"
159   Option        \"MaxSpeed\"      \"0.12\"
160   Option        \"AccelFactor\" \"0.0010\"
161 #  Option       \"SHMConfig\"     \"on\"
162 #  Option       \"Repeater\"      \"/dev/ps2mouse\"
163 EndSection
164 "
165     else
166      MOUSEDRIVER='mouse'
167      SYNMOUSEDETAIL=""
168      SYNMOUSE='# No synaptics touchpad detected.'
169     fi
170    else
171
172     # AlpsPS/2 ALPS TouchPad (with Synapticsdriver)
173     if grep -q 'Device:.*ALPS' "$MOUSEINFO" ; then
174      if [[ "$SYNAPTICS" == "yes" ]] ; then # check for '-nosynaptics'-option
175       MOUSEDRIVER='synaptics'
176       # SYNMOUSE='InputDevice    "Synaptics" "CorePointer"'
177       SYNMOUSE='InputDevice    "Synaptics"  "AlwaysCore"'
178       SYNMOUSEDETAIL="
179 Section \"InputDevice\"
180   Driver        \"synaptics\"
181   Identifier    \"Synaptics\"
182   Option        \"Device\"        \"/dev/psaux\"
183   Option        \"Protocol\"      \"auto-dev\"
184   Option        \"LeftEdge\"      \"120\"
185   Option        \"RightEdge\"     \"850\"
186   Option        \"TopEdge\"       \"120\"
187   Option        \"BottomEdge\"    \"650\"
188   Option        \"FingerLow\"     \"14\"
189   Option        \"FingerHigh\"    \"15\"
190   Option        \"ZAxisMapping\"   \"4 5\"
191   Option        \"MaxTapTime\"    \"180\"
192   Option        \"MaxTapMove\"    \"50\"
193   Option        \"MaxDoubleTapTime\"    \"100\"
194   Option        \"VertScrollDelta\" \"20\"
195   Option        \"HorizScrollDelta\" \"20\"
196   Option        \"MinSpeed\"      \"0.3\"
197   Option        \"MaxSpeed\"      \"2.00\"
198   Option        \"AccelFactor\" \"0.030\"
199   Option        \"UpDownScrolling\" \"1\"
200   Option        \"EmulateMiddleButtonTime\" \"75\"
201   Option        \"CircularScrolling\" \"1\"
202   Option        \"CircScrollDelta\" \"0.1\"
203   Option        \"CircScrollTrigger\" \"8\"
204 #  Option       \"SHMConfig\"     \"on\"
205 #  Option       \"Repeater\"      \"/dev/ps2mouse\"
206 EndSection
207 "
208      else
209       MOUSEDRIVER='mouse'
210       SYNMOUSEDETAIL=""
211       SYNMOUSE='# No alps touchpad detected.'
212      fi
213     else
214       SYNMOUSE='# No alps touchpad present.'
215     fi
216    fi
217
218    # USB-PS/2 Optical Mouse
219 #   if grep -q 'Device:.*USB' "$MOUSEINFO" ; then
220    if ! [[ -n $NOUSB ]] ; then
221      USB='yes'
222      USBMOUSE='InputDevice    "USB Mouse"  "CorePointer"'
223      USBMOUSEDETAIL="
224 Section \"InputDevice\"
225         Identifier      \"USB Mouse\"
226         Driver          \"mouse\"
227         Option          \"Device\"                \"/dev/input/mice\"
228         Option          \"Protocol\"              \"auto\"
229         Option          \"ZAxisMapping\"          \"4 5\"
230         Option          \"Buttons\"               \"5\"
231         Option          \"SendCoreEvents\"        \"true\"
232 EndSection
233 "
234    else
235      USBMOUSE='# Deactivated USB Mouse as requested.'
236    fi
237
238    if grep -q 'Device:.*Serial' "$MOUSEINFO" ; then
239      SERIAL='yes'
240      SERMOUSE='InputDevice    "Serial Mouse" "CorePointer"'
241      SERMOUSEDETAIL="
242 Section \"InputDevice\"
243         Identifier  \"Serial Mouse\"
244         Driver      \"mouse\"
245         Option      \"Device\" \"/dev/ttyS0\"
246         Option      \"Protocol\" \"Microsoft\"
247         Option      \"Emulate3Buttons\" \"true\"
248         Option      \"Emulate3Timeout\" \"70\"
249         Option      \"SendCoreEvents\"  \"true\"
250 EndSection
251 "
252    else
253      SERMOUSE='# No serial mouse detected.'
254    fi
255
256    # ImExPS/2 Logitech Explorer Mouse
257    # "PS2++ Logitech MX Mouse"
258    if ! [[ -n $NOPS2 ]] ; then
259      if grep -qE 'Device:.*PS.?2' "$MOUSEINFO" ; then
260        PS2='yes'
261        PS2MOUSE='InputDevice    "PS/2 Mouse" "CorePointer"'
262        PS2MOUSEDETAIL="
263 Section \"InputDevice\"
264         Identifier  \"PS/2 Mouse\"
265         Driver      \"mouse\"
266         Option      \"Device\" \"/dev/input/mice\"
267         # Option      \"Device\" \"/dev/psaux\"
268         Option      \"Protocol\" \"PS/2\"
269         Option      \"Emulate3Buttons\" \"true\"
270         Option      \"Emulate3Timeout\" \"70\"
271         Option      \"SendCoreEvents\"  \"true\"
272 EndSection
273 "
274      else
275        PS2MOUSE='# No PS/2 mouse detected.'
276        PS2MOUSEDETAIL=""
277      fi
278    else
279      PS2MOUSE='# Deactivated PS/2 Mouse as requested.'
280    fi
281
282    if [[ -n $GENERICMOUSE ]] ; then
283      GENERIC='yes'
284      GENERICMOUSE='InputDevice    "Generic Mouse" "CorePointer"'
285      GENERICMOUSEDETAIL="
286 Section \"InputDevice\"
287         Identifier  \"Generic Mouse\"
288         Driver      \"mouse\"
289         Option      \"Device\" \"/dev/input/mice\"
290         Option      \"Protocol\" \"auto\"
291         Option      \"Buttons\" \"5\"
292         Option      \"ZAxisMapping\" \"4 5\"
293 EndSection
294 "
295    else
296      GENERICMOUSE='# No generic mouse configured.'
297    fi
298
299    MOUSE="        $USBMOUSE
300         $PS2MOUSE
301         $SYNMOUSE
302         $GENERICMOUSE
303         $SERMOUSE"
304 }
305 # }}}
306
307 # commandline parsing {{{
308 parse_options()
309 {
310    # default values
311    #o_xserver=(-xserver XFree86)
312    #o_hsync=(-hsync '28.0 - 96.0')
313    #o_vsync=(-vsync '50.0 - 60.0')
314
315    zparseopts -K -- xserver:=o_xserver module:=o_module help=o_help noddc=o_noddc nosync=o_nosync \
316                     vsync:=o_vsync hsync:=o_hsync mode:=o_mode force=o_force display:=o_display   \
317                     nostart=o_nostart nodpms=o_nodpms nosynaptics=o_nosynaptics nousb=o_nousb \
318                     nops2=o_nops2 genmouse=o_genmouse novref=o_novref nohsync=o_nohsync
319
320    if [[ $# == 0 || "$o_help" != "" || "$1" == '-h' || "$1" == '--help' ]]; then
321       usage
322    fi
323
324    if [[ "$o_force" != "" ]]; then
325       FORCE="yes"
326    fi
327
328    if [[ "$o_nodpms" != "" ]]; then
329       DPMS='Option       "DPMS"      "false"'
330    else
331       DPMS='Option       "DPMS"      "true"'
332    fi
333
334    if [[ "$o_noddc" != "" ]]; then
335       NODDC="yes"
336    fi
337
338    if [[ "$o_vsync" != "" ]]; then
339       FORCE="yes"
340    fi
341
342    if [[ "$o_hsync" != "" ]]; then
343       FORCE="yes"
344    fi
345
346    if [[ "$o_xserver" != "" ]]; then
347       FORCE="yes"
348    fi
349
350    if [[ "$o_nousb" != "" ]]; then
351       NOUSB='yes'
352    fi
353
354    if [[ "$o_nops2" != "" ]]; then
355       NOPS2='yes'
356    fi
357
358    if [[ "$o_genmouse" != "" ]]; then
359       GENERICMOUSE='yes'
360    fi
361
362    if [[ "$o_nosynaptics" != "" ]]; then
363       SYNAPTICS='no'
364    else
365       SYNAPTICS='yes'
366    fi
367
368    if [[ "$o_nostart" != "" ]]; then
369       NOSTART="yes"
370    fi
371
372    DISPLAY=$o_display[2]
373    if [ -z $o_hsync ] ; then
374      o_hsync=(-hsync "$hsyncval")
375      HSYNC=$o_hsync[2]
376      HORIZSYNC="        HorizSync    $HSYNC"
377    else
378      o_hsync=(-hsync "$o_hsync[2]")
379      HSYNC=$o_hsync[2]
380      HORIZSYNC="        HorizSync    $HSYNC"
381    fi
382
383    if [ -z $o_vsync ] ; then
384      o_vsync=(-vsync "$vsyncval")
385      VSYNC=$o_vsync[2]
386      VERTISYNC="        VertRefresh  $VSYNC"
387    else
388      o_vsync=(-vsync "$o_vsync[2]")
389      VSYNC=$o_vsync[2]
390      VERTISYNC="        VertRefresh  $VSYNC"
391    fi
392
393    if [[ "$o_nosync" != "" ]]; then
394       HORIZSYNC="#       HorizSync   28.0 - 96.0  # deactivated via -nosync option of grml-x"
395       VERTISYNC="#       VertRefresh 50.0 - 60.0  # deactivated via -nosync option of grml-x"
396    fi
397    if [[ "$o_nohsync" != "" ]]; then
398       HORIZSYNC="#       HorizSync   28.0 - 96.0  # deactivated via -nohsync option of grml-x"
399    fi
400    if [[ "$o_novref" != "" ]]; then
401       VERTISYNC="#       VertRefresh 50.0 - 60.0  # deactivated via -novref option of grml-x"
402    fi
403
404    eval WINDOWMANAGER=\${$#}
405
406    XSERVER=$o_xserver[2]
407    if [[ -n $(X -version 2>&1| grep XFree86) || "$XSERVER" == XFree86 ]] ; then
408       XSERVER="XFree86"
409       XCONFIG='/etc/X11/XF86Config-4'
410       KEYBOARD="Driver      \"keyboard\"
411         Option      \"XkbRules\" \"xfree86\"
412         Option      \"XkbModel\" \"pc105\"
413         Option      \"XkbLayout\" \"${XKEYBOARD},us\"
414         # Option      \"XkbVariant\" \"nodeadkeys\""
415    elif [[ -n $(X -version 2>&1 | grep -e 'X\.Org' -e 'Version 7\.') || "$XSERVER" == Xorg ]] ; then
416       XSERVER="Xorg"
417       XCONFIG='/etc/X11/xorg.conf'
418       KEYBOARD="Driver      \"kbd\"
419         # Option      \"XkbRules\"   \"xfree86\"
420         Option      \"XkbRules\"   \"xorg\"
421         Option      \"XkbModel\"   \"pc105\"
422         Option      \"XkbLayout\"  \"${XKEYBOARD},us\"
423         # Option      \"XkbVariant\" \"nodeadkeys\""
424    fi
425
426    # check for font path
427    if [ -d /usr/share/fonts/X11 ] ; then
428       XFONTS="        FontPath     \"/usr/share/fonts/X11/misc\"
429         FontPath     \"/usr/share/fonts/X11/cyrillic\"
430         FontPath     \"/usr/share/fonts/X11/100dpi/:unscaled\"
431         FontPath     \"/usr/share/fonts/X11/75dpi/:unscaled\"
432         FontPath     \"/usr/share/fonts/X11/Type1\"
433         FontPath     \"/usr/share/fonts/X11/100dpi\"
434         FontPath     \"/usr/share/fonts/X11/75dpi\""
435    fi
436    if [ -d /usr/X11R6/lib/X11/fonts ] ; then
437        XFONTS="$XFONTS
438         FontPath     \"/usr/X11R6/lib/X11/fonts/misc:unscaled\"
439         FontPath     \"/usr/X11R6/lib/X11/fonts/misc\"
440         FontPath     \"/usr/X11R6/lib/X11/fonts/75dpi:unscaled\"
441         FontPath     \"/usr/X11R6/lib/X11/fonts/75dpi\"
442         FontPath     \"/usr/X11R6/lib/X11/fonts/100dpi:unscaled\"
443         FontPath     \"/usr/X11R6/lib/X11/fonts/100dpi\""
444    fi
445
446    if [[ "$XKEYBOARD" == de ]] ; then
447        KEYBOARD="$KEYBOARD
448        Option      \"XkbVariant\" \"nodeadkeys\""
449    fi
450
451    print -n "$bold_color$fg[blue]Gathering hardware information: $fg[red]"
452
453    writehwinfo
454    MONITOR=$(awk '/monitor.1:/{print $3}' $HWINFO_TMP)
455    if [[ $MONITOR != 'ddc' ]] ; then
456      NODDC=yes
457    fi
458    MODULE=$o_module[2]
459    if [ -z $MODULE ] ; then
460      MODULE="$(getBootParam xmodule 2>/dev/null)"
461      if [ -z "$MODULE" ] ; then
462        MODULE=$(grep 'XFree86 v4 Server Module:' "${HWINFO_TMP}" | head -1 | awk '{print $5}')
463        if [ -z  "$MODULE" ] ; then
464          MODULE='vesa'
465        fi
466      fi
467    else
468      FORCE="yes"
469    fi
470
471    mouse    # get mouse settings
472    VGA=$(lspci | grep VGA | sed 's/.*compatible controller: //' | head -1)
473
474    MODE=$o_mode[2]
475    if [ -z $MODE ] ; then
476      B_MODE="$(getBootParam xmode 2>/dev/null)"
477      if [ -n "$B_MODE" ] ; then
478        MODES="Modes \"$B_MODE\""
479        FORCE="yes"
480      fi
481      if [ -z "$MODES" ] ; then
482        mode # get available modes
483      fi
484    else
485      MODES="Modes \"$MODE\""
486      FORCE="yes"
487    fi
488
489    print "$fg[green]done$reset_color"
490
491
492    print "$bg[black]$fg[white]$bold_color"
493    print "$fg[green]Specified windowmanager is $fg[yellow]$WINDOWMANAGER"
494    print "$fg[green]Video is $fg[yellow]$VGA$fg[green] using $bg[black]$fg[yellow]${XSERVER}$fg[cyan](${MODULE})$fg[green] Server"
495    [[ -z $HSYNC ]] && [[ -z $VSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR"
496    [[ -z $HSYNC ]] && [[ -n $VSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR$fg[green], VSYNC: $fg[yellow]$VSYNC"
497    [[ -z $VSYNC ]] && [[ -n $HSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR$fg[green], HSYNC: $fg[yellow]$HSYNC"
498    [[ -n $VSYNC ]] && [[ -n $HSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR$fg[green], HSYNC: $fg[yellow]$HSYNC $fg[green]VSYNC: $fg[yellow]$VSYNC"
499    [[ -n $modes ]] && print "$fg[green]Using default X.org modes."
500    [[ -z $modes ]] && print "$fg[green]Using Mode: $fg[yellow]$MODE"
501 #   [[ -n $MODE ]] && print "$fg[green]Using Mode: $fg[yellow]$MODE"
502 #   [[ -z $MODE ]] && print "$fg[green]Using default modes."
503    print "${reset_color}"
504 #   if [[ $module[1] != ./. ]]; then module="$PWD/$module"; fi
505 }
506 parse_options $*
507 # }}}
508
509 # check for requirements {{{
510 requirements()
511 {
512 if ! [ -x $(which hwinfo) ] ; then
513   print "$bg[black]$fg[red]${bold_color}Error: hwinfo not found in path.${reset_color}
514 Note:  run 'apt-get install hwinfo' on systems running debian.
515 Exiting.${reset_color}"
516   exit -1
517 fi
518
519 if ! [[ -d /sys ]] ; then
520   print "$bg[black]$fg[red]${bold_color}Error: mounted /sys required (for hwinfo).${reset_color}
521 You may want to add the following line to your /etc/fstab:
522
523   sysfs /sys sysfs defaults 0 0
524
525 or just run 'mount /sys'. Exiting.${reset_color}"
526   exit -1
527 fi
528 }
529 requirements
530 # }}}
531
532 # xconfig {{{
533 xconfig() {
534 cat << EOX
535 ################################################################################
536 # Filename:      $XCONFIG
537 # Purpose:       config file for xserver - generated by grml-x
538 # Bug-Reports:   see http://grml.org/bugs/
539 # Latest change: ${DATE}
540 # See also:
541 #   /usr/share/doc/xserver-xorg/   and
542 #   http://wiki.x.org/wiki/Home    and
543 #   http://ftp.x.org/pub/X11R7.0/doc/html/index.html for information on Xorg
544 #   /usr/share/doc/xfree86-common/                   for information on XFree86
545 # Refer to the xorg.conf man page and to
546 # http://ftp.x.org/pub/X11R7.0/doc/html/xorg.conf.5.html
547 # for details about the format of this file.
548
549 # If you would like this file to be automatically reconfigured by debian,
550 # run the following command:
551 #   sudo dpkg-reconfigure -phigh xserver-xorg
552 ################################################################################
553
554 Section "ServerLayout"
555         Identifier     "XServer Configured"
556         Screen      0  "Screen0" 0 0
557         InputDevice    "Keyboard0"  "CoreKeyboard"
558 $MOUSE
559 EndSection
560
561 Section "ServerFlags"
562         Option "AllowMouseOpenFail"  "true"  # allows the server to start up even if the mouse does not work
563         Option "DontVTSwitch"        "false" # allow switching between virtual terminal
564         # Option "DontZap"             "true"  # disable <Crtl><Alt><BS> (server abort)
565         # Option "DontZoom"            "true"  # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching)
566 EndSection
567
568 Section "Files"
569 #        RgbPath      "/usr/X11R6/lib/X11/rgb"
570 #        ModulePath   "/usr/X11R6/lib/modules"
571 # More information:  http://ftp.x.org/pub/X11R7.0/doc/html/fonts.html
572 $XFONTS
573 # check:
574 #       FontPath     "/usr/X11R6/lib/X11/fonts/Speedo"
575 #       FontPath     "/usr/X11R6/lib/X11/fonts/PEX"
576 #       FontPath     "/usr/X11R6/lib/X11/fonts/encodings"
577 #       FontPath     "/usr/X11R6/lib/X11/fonts/Type1
578 #       FontPath     "/usr/X11R6/lib/X11/fonts/util
579 # Additional fonts: Locale, Gimp, TTF...
580 #       FontPath     "/usr/X11R6/lib/X11/fonts/cyrillic"
581 #       FontPath     "/usr/X11R6/lib/X11/fonts/latin2/75dpi"
582 #       FontPath     "/usr/X11R6/lib/X11/fonts/latin2/100dpi"
583 # True type and type1 fonts are also handled via xftlib, see /etc/X11/XftConfig!
584         FontPath     "/usr/X11R6/lib/X11/fonts/Type1"
585         FontPath     "/usr/share/fonts/ttf/western"
586         FontPath     "/usr/share/fonts/ttf/decoratives"
587 #        FontPath     "/usr/share/fonts/truetype"
588 #        FontPath     "/usr/share/fonts/truetype/openoffice"
589         FontPath     "/usr/share/fonts/truetype/ttf-bitstream-vera"
590 #       FontPath     "/usr/share/fonts/truetype/latex-xft-fonts"
591         FontPath     "/usr/share/fonts/latex-ttf-fonts"
592         FontPath     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
593 #       FontPath     "/usr/X11R6/lib/X11/fonts/defoma/TrueType"
594 #       FontPath     "/usr/X11R6/lib/X11/fonts/defoma/CID"
595 EndSection
596
597 # Modules - see /usr/X11R6/lib/modules/fonts and /usr/X11R6/lib/modules/extensions
598 Section "Module"
599         Load  "dbe"       # double buffer extension
600         Load  "dri"       # direct rendering
601         Load  "glx"       # 3D layer
602         Load  "type1"     # font module
603         Load  "freetype"  # font rendering
604         Load  "extmod"    # some commonly used server extensions (e.g. shape extension)
605         Load  "record"    # recording extension
606         # Load  "vbe"       # Vesa BIOS Extension
607         # Load  "ddc"       # ddc probing of monitor
608         # Load  "bitmap"    # bitmap fonts
609         # Load  "GLcore"    # render OpenGL in software
610         # Load  "i2c"       # I2C bus
611         # Load  "int10"     # initialize graphics cards via int10 call to the BIOS
612         # Load  "speedo"    # font module
613         # Load  "v4l"       # Video for Linux
614         # Load  "evdev"     # generic input handling driver on Linux
615 # Valid entries - see /usr/lib/xorg/modules/[extensions/]
616 # afb bitmap cfb cfb16 cfb24 cfb32 cw damage dbe ddc dri drm extmod fb
617 # fbdevhw freetype GLcore glx i2c int10 int10 layer mfb pcidata rac ramdac
618 # record scanpci shadow shadowfb type1 vbe vgahw xaa xf1bpp xf24_32bpp xf4bpp
619 # xf8_16bpp xf8_32bpp xtrap
620 EndSection
621
622 # If you'd like to switch the positions of your capslock and control keys, use:
623 # Option "XkbOptions" "ctrl:swapcaps"
624 # Or if you just want both to be control, use:
625 # Option "XkbOptions" "ctrl:nocaps"
626 # More information: http://ftp.x.org/pub/X11R7.0/doc/html/XKB-Config.html
627 Section "InputDevice"
628         Identifier  "Keyboard0"
629         Option      "CoreKeyboard"
630         $KEYBOARD
631         # Option      "XkbOptions" "ctrl:swapcaps,grp:alt_shift_toggle,grp_led:scroll,compose:menu"
632 EndSection
633
634 # More information: http://ftp.x.org/pub/X11R7.0/doc/html/mouse.html
635 $GENERICMOUSEDETAIL
636 $USBMOUSEDETAIL
637 $PS2MOUSEDETAIL
638 $SERMOUSEDETAIL
639 $SYNMOUSEDETAIL
640 Section "Monitor"
641         Identifier   "Monitor0"
642 #       ModelName    "Old Monitor (no DDC)"
643         $DPMS
644 #       HorizSync    28.0 - 78.0 # Warning: This may fry very old Monitors
645 #       HorizSync    28.0 - 96.0 # Warning: This may fry old Monitors
646 $HORIZSYNC
647 #       VertRefresh  50.0 - 76.0 # Very conservative. May flicker.
648 #       VertRefresh  50.0 - 60.0 # Extreme conservative. Will flicker. TFT default.
649 $VERTISYNC
650 # Need more information?
651 #  http://xtiming.sourceforge.net/cgi-bin/xtiming.pl
652 #  http://en.tldp.org/HOWTO/XFree86-Video-Timings-HOWTO/
653 EndSection
654
655 Section "Device"
656         ### Available Driver options are:
657         ## sw_cursor is needed for some ati and radeon cards
658         # Option     "sw_cursor"
659         # Option     "hw_cursor"
660         # Option     "NoAccel"
661         # Option     "ShowCache"
662         # Option     "ShadowFB"
663         # Option     "UseFBDev"
664         # Option     "Rotate"
665         ## xorg + nvidia:
666         # Option "RenderAccel" "true"
667         # Option "AllowGLXWithComposite" "true"
668         Identifier  "Card0"
669 # The following line is auto-generated by grml-x
670         Driver      "$MODULE"
671         VendorName  "All"
672         BoardName   "All"
673         ## Workaround for drivers which send output to wrong device:
674         # Option "MonitorLayout" "LVDS, AUTO"
675         # Option "MonitorLayout" "LVDS, CRT"
676         # Option "MonitorLayout" "NONE, STV"
677         # Option "MonitorLayout" "LVDS"
678         ## Specify BusID:
679         # BusID       "PCI:1:0:0"
680 EndSection
681
682 Section "Screen"
683         Identifier "Screen0"
684         Device     "Card0"
685         Monitor    "Monitor0"
686         DefaultColorDepth 16
687         SubSection "Display"
688                 Depth     1
689                 $MODES
690         EndSubSection
691         SubSection "Display"
692                 Depth     4
693                 $MODES
694         EndSubSection
695         SubSection "Display"
696                 Depth     8
697                 $MODES
698         EndSubSection
699         SubSection "Display"
700                 Depth     15
701                 $MODES
702         EndSubSection
703         SubSection "Display"
704                 Depth     16
705                 $MODES
706         EndSubSection
707         SubSection "Display"
708                 Depth     24
709                 $MODES
710         EndSubSection
711         SubSection "Display"
712                 Depth     32
713                 $MODES
714         EndSubSection
715 EndSection
716
717 Section "DRI"
718         Mode 0666
719 EndSection
720
721 #Section "Extensions"
722 #    Option "Composite" "Enable"
723 #EndSection
724
725 ## END OF FILE #################################################################
726 EOX
727 }
728 # }}}
729
730 # writeit {{{
731 writeit() {
732     XCONFTMP="/tmp/xconfig.$$"
733     xconfig > $XCONFTMP
734     [ -f $XCONFIG ] && sudo mv -f $XCONFIG $XCONFIG.old
735     sudo mv $XCONFTMP $XCONFIG
736     sudo chown root.root $XCONFIG
737     sudo chmod 644 $XCONFIG
738 }
739 # }}}
740
741 # writeconfig {{{
742 function writeconfig
743 {
744   if [[ ! -f $XCONFIG ]] ; then
745     print -n "$bold_color$fg[blue]Creating $XCONFIG: $fg[red]"
746     writeit && print "$fg[green]done$reset_color"
747   else
748     print "$bold_color$fg[blue]Notice: $XCONFIG exists already.
749 Use the force-option (-force) to force creation.
750 $fg[red]"
751   fi
752   if [[ -n "$FORCE" ]] ; then
753     print "$bold_color$fg[blue]Force-switch or manual option(s) detected -"
754     print -n "moving eventual existing $XCONFIG to ${XCONFIG}.old: $fg[red]"
755     writeit && print "$fg[green]done$reset_color"
756   fi
757 }
758 # }}}
759
760 # runit {{{
761 function runit
762 {
763   writeconfig
764   if [ -z $NOSTART ] ; then
765     print "$reset_color"
766     if [ -x /etc/init.d/xorg-common ] ; then
767       sudo /etc/init.d/xorg-common start
768     else
769       if [ -x /etc/init.d/xfree86-common ] ; then
770         sudo /etc/init.d/xfree86-common start
771       fi
772     fi
773     print ""
774     if [ -z $DISPLAY ] ; then
775       print "$bold_color$fg[green]Now trying to run startx.$reset_color"
776       startx ~/.xinitrc -- $XOPTS
777     else
778       print "$bold_color$fg[green]Now trying to run startx on display $DISPLAY.$reset_color"
779       startx ~/.xinitrc -- :$DISPLAY $XOPTS
780     fi
781   else
782     print "$bold_color$fg[blue]Not running startx as requested as option.$reset_color"
783   fi
784   return 1
785 }
786 # }}}
787
788 # failed {{{
789 function failed
790 {
791   print "$fg[red]"
792   if [ $UID != 0 ] ; then
793     if [[ $(tty) == /dev/pts/* ]] ; then
794       print "It seems you are running $PROGRAMNAME from inside GNU screen.
795 Notice that this might fail if running as user grml!
796 Please exit screen and try to run $PROGRAMNAME again."
797     fi
798   fi
799   print "
800 Problems? Run the following commands for getting information on your hardware:
801   hwinfo --gfxcard
802   discover -v --data-path=xfree86/server/device/driver display
803   xdebconfigurator -c -d -i -x
804   get-edid | parse-edid
805
806 Do you want to go the debian way of life? Run:
807   apt-get install x-window-system-core read-edid mdetect hwinfo xdebconfigurator
808   dpkg-reconfigure x-window-system-core (or xserver-xfree86 or xserver-xorg depending on your system)
809
810 Problems with the module used for X? Try to load another one or
811 fall back to module vesa:
812   $PROGRAMNAME -module radeon ...
813   $PROGRAMNAME -module vesa  ...
814
815 Do you want to deactivate a present synaptics touchpad? Run:
816   $PROGRAMNAME -nosynaptics ...
817
818 Your monitor is very old and/or does not support DDC-probing?
819   $PROGRAMNAME -noddc ...
820
821 Do you want to create a x configuration file but do not start X?
822   $PROGRAMNAME -nostart ...
823
824 Monitor frequency too high or too low? Just specify hsync/vsync manually:
825   $PROGRAMNAME -hsync 30-65 ...
826   $PROGRAMNAME -hsync 30-65 -vsync 50-60 ...
827
828 Want to adjust the resolution? Use the mode-switch:
829   $PROGRAMNAME -mode 1024x768 ...
830   $PROGRAMNAME -mode '1280x1024 1024x768' ...
831
832 To adjust resolution while running X execute:
833   xrandr -s '1024x768'
834
835 More information on grml-x can be found in the manual page: man grml-x
836
837 Report bugs, send wishes and feedback to the grml team:
838 http://grml.org/bugs/ - contact (at) grml.org
839 "
840 print -n "$reset_color"
841 }
842 # }}}
843
844 # cleanup {{{
845 cleanup()
846 {
847   rm -f $HWINFO_TMP
848   rm -f $MONITORINFO
849   rm -f $MOUSEINFO
850   rm -f $XCONFTMP
851 }
852 cleanup
853 # }}}
854
855 # xinitrc {{{
856   if [ -w $XINITRC ] ; then
857     sed -i "s|^[^#]*exec.*|  exec $WINDOWMANAGER|g" $XINITRC
858     runit || failed
859   else
860     echo -e "#!/bin/sh\n  exec $WINDOWMANAGER" >> $XINITRC
861     runit || failed
862   fi
863 # }}}
864
865 ## END OF FILE #################################################################
866 # vim:foldmethod=marker