add us to XkbLayout no matter which language is detected.
[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      mode # get available modes
477    else
478      MODES="Modes \"$MODE\""
479      FORCE="yes"
480    fi
481
482    print "$fg[green]done$reset_color"
483
484
485    print "$bg[black]$fg[white]$bold_color"
486    print "$fg[green]Specified windowmanager is $fg[yellow]$WINDOWMANAGER"
487    print "$fg[green]Video is $fg[yellow]$VGA$fg[green] using $bg[black]$fg[yellow]${XSERVER}$fg[cyan](${MODULE})$fg[green] Server"
488    [[ -z $HSYNC ]] && [[ -z $VSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR"
489    [[ -z $HSYNC ]] && [[ -n $VSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR$fg[green], VSYNC: $fg[yellow]$VSYNC"
490    [[ -z $VSYNC ]] && [[ -n $HSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR$fg[green], HSYNC: $fg[yellow]$HSYNC"
491    [[ -n $VSYNC ]] && [[ -n $HSYNC ]] && print "$fg[green]Monitor is $fg[yellow]$MONITOR$fg[green], HSYNC: $fg[yellow]$HSYNC $fg[green]VSYNC: $fg[yellow]$VSYNC"
492    [[ -n $modes ]] && print "$fg[green]Using default X.org modes."
493    [[ -z $modes ]] && print "$fg[green]Using Mode: $fg[yellow]$MODE"
494 #   [[ -n $MODE ]] && print "$fg[green]Using Mode: $fg[yellow]$MODE"
495 #   [[ -z $MODE ]] && print "$fg[green]Using default modes."
496    print "${reset_color}"
497 #   if [[ $module[1] != ./. ]]; then module="$PWD/$module"; fi
498 }
499 parse_options $*
500 # }}}
501
502 # check for requirements {{{
503 requirements()
504 {
505 if ! [ -x $(which hwinfo) ] ; then
506   print "$bg[black]$fg[red]${bold_color}Error: hwinfo not found in path.${reset_color}
507 Note:  run 'apt-get install hwinfo' on systems running debian.
508 Exiting.${reset_color}"
509   exit -1
510 fi
511
512 if ! [[ -d /sys ]] ; then
513   print "$bg[black]$fg[red]${bold_color}Error: mounted /sys required (for hwinfo).${reset_color}
514 You may want to add the following line to your /etc/fstab:
515
516   sysfs /sys sysfs defaults 0 0
517
518 or just run 'mount /sys'. Exiting.${reset_color}"
519   exit -1
520 fi
521 }
522 requirements
523 # }}}
524
525 # xconfig {{{
526 xconfig() {
527 cat << EOX
528 ################################################################################
529 # Filename:      $XCONFIG
530 # Purpose:       config file for xserver - generated by grml-x
531 # Bug-Reports:   see http://grml.org/bugs/
532 # Latest change: ${DATE}
533 # See also:
534 #   /usr/share/doc/xserver-xorg/   and
535 #   http://wiki.x.org/wiki/Home    and
536 #   http://ftp.x.org/pub/X11R7.0/doc/html/index.html for information on Xorg
537 #   /usr/share/doc/xfree86-common/                   for information on XFree86
538 # Refer to the xorg.conf man page and to
539 # http://ftp.x.org/pub/X11R7.0/doc/html/xorg.conf.5.html
540 # for details about the format of this file.
541
542 # If you would like this file to be automatically reconfigured by debian,
543 # run the following command:
544 #   sudo dpkg-reconfigure -phigh xserver-xorg
545 ################################################################################
546
547 Section "ServerLayout"
548         Identifier     "XServer Configured"
549         Screen      0  "Screen0" 0 0
550         InputDevice    "Keyboard0"  "CoreKeyboard"
551 $MOUSE
552 EndSection
553
554 Section "ServerFlags"
555         Option "AllowMouseOpenFail"  "true"  # allows the server to start up even if the mouse does not work
556         Option "DontVTSwitch"        "false" # allow switching between virtual terminal
557         # Option "DontZap"             "true"  # disable <Crtl><Alt><BS> (server abort)
558         # Option "DontZoom"            "true"  # disable <Crtl><Alt><KP_+>/<KP_-> (resolution switching)
559 EndSection
560
561 Section "Files"
562 #        RgbPath      "/usr/X11R6/lib/X11/rgb"
563 #        ModulePath   "/usr/X11R6/lib/modules"
564 # More information:  http://ftp.x.org/pub/X11R7.0/doc/html/fonts.html
565 $XFONTS
566 # check:
567 #       FontPath     "/usr/X11R6/lib/X11/fonts/Speedo"
568 #       FontPath     "/usr/X11R6/lib/X11/fonts/PEX"
569 #       FontPath     "/usr/X11R6/lib/X11/fonts/encodings"
570 #       FontPath     "/usr/X11R6/lib/X11/fonts/Type1
571 #       FontPath     "/usr/X11R6/lib/X11/fonts/util
572 # Additional fonts: Locale, Gimp, TTF...
573 #       FontPath     "/usr/X11R6/lib/X11/fonts/cyrillic"
574 #       FontPath     "/usr/X11R6/lib/X11/fonts/latin2/75dpi"
575 #       FontPath     "/usr/X11R6/lib/X11/fonts/latin2/100dpi"
576 # True type and type1 fonts are also handled via xftlib, see /etc/X11/XftConfig!
577         FontPath     "/usr/X11R6/lib/X11/fonts/Type1"
578         FontPath     "/usr/share/fonts/ttf/western"
579         FontPath     "/usr/share/fonts/ttf/decoratives"
580 #        FontPath     "/usr/share/fonts/truetype"
581 #        FontPath     "/usr/share/fonts/truetype/openoffice"
582         FontPath     "/usr/share/fonts/truetype/ttf-bitstream-vera"
583 #       FontPath     "/usr/share/fonts/truetype/latex-xft-fonts"
584         FontPath     "/usr/share/fonts/latex-ttf-fonts"
585         FontPath     "/var/lib/defoma/x-ttcidfont-conf.d/dirs/TrueType"
586 #       FontPath     "/usr/X11R6/lib/X11/fonts/defoma/TrueType"
587 #       FontPath     "/usr/X11R6/lib/X11/fonts/defoma/CID"
588 EndSection
589
590 # Modules - see /usr/X11R6/lib/modules/fonts and /usr/X11R6/lib/modules/extensions
591 Section "Module"
592         Load  "dbe"       # double buffer extension
593         Load  "dri"       # direct rendering
594         Load  "glx"       # 3D layer
595         Load  "type1"     # font module
596         Load  "freetype"  # font rendering
597         Load  "extmod"    # some commonly used server extensions (e.g. shape extension)
598         Load  "record"    # recording extension
599         # Load  "vbe"       # Vesa BIOS Extension
600         # Load  "ddc"       # ddc probing of monitor
601         # Load  "bitmap"    # bitmap fonts
602         # Load  "GLcore"    # render OpenGL in software
603         # Load  "i2c"       # I2C bus
604         # Load  "int10"     # initialize graphics cards via int10 call to the BIOS
605         # Load  "speedo"    # font module
606         # Load  "v4l"       # Video for Linux
607         # Load  "evdev"     # generic input handling driver on Linux
608 # Valid entries - see /usr/lib/xorg/modules/[extensions/]
609 # afb bitmap cfb cfb16 cfb24 cfb32 cw damage dbe ddc dri drm extmod fb
610 # fbdevhw freetype GLcore glx i2c int10 int10 layer mfb pcidata rac ramdac
611 # record scanpci shadow shadowfb type1 vbe vgahw xaa xf1bpp xf24_32bpp xf4bpp
612 # xf8_16bpp xf8_32bpp xtrap
613 EndSection
614
615 # If you'd like to switch the positions of your capslock and control keys, use:
616 # Option "XkbOptions" "ctrl:swapcaps"
617 # Or if you just want both to be control, use:
618 # Option "XkbOptions" "ctrl:nocaps"
619 # More information: http://ftp.x.org/pub/X11R7.0/doc/html/XKB-Config.html
620 Section "InputDevice"
621         Identifier  "Keyboard0"
622         Option      "CoreKeyboard"
623         $KEYBOARD
624         # Option      "XkbOptions" "ctrl:swapcaps,grp:alt_shift_toggle,grp_led:scroll,compose:menu"
625 EndSection
626
627 # More information: http://ftp.x.org/pub/X11R7.0/doc/html/mouse.html
628 $GENERICMOUSEDETAIL
629 $USBMOUSEDETAIL
630 $PS2MOUSEDETAIL
631 $SERMOUSEDETAIL
632 $SYNMOUSEDETAIL
633 Section "Monitor"
634         Identifier   "Monitor0"
635 #       ModelName    "Old Monitor (no DDC)"
636         $DPMS
637 #       HorizSync    28.0 - 78.0 # Warning: This may fry very old Monitors
638 #       HorizSync    28.0 - 96.0 # Warning: This may fry old Monitors
639 $HORIZSYNC
640 #       VertRefresh  50.0 - 76.0 # Very conservative. May flicker.
641 #       VertRefresh  50.0 - 60.0 # Extreme conservative. Will flicker. TFT default.
642 $VERTISYNC
643 # Need more information?
644 #  http://xtiming.sourceforge.net/cgi-bin/xtiming.pl
645 #  http://en.tldp.org/HOWTO/XFree86-Video-Timings-HOWTO/
646 EndSection
647
648 Section "Device"
649         ### Available Driver options are:
650         ## sw_cursor is needed for some ati and radeon cards
651         # Option     "sw_cursor"
652         # Option     "hw_cursor"
653         # Option     "NoAccel"
654         # Option     "ShowCache"
655         # Option     "ShadowFB"
656         # Option     "UseFBDev"
657         # Option     "Rotate"
658         ## xorg + nvidia:
659         # Option "RenderAccel" "true"
660         # Option "AllowGLXWithComposite" "true"
661         Identifier  "Card0"
662 # The following line is auto-generated by grml-x
663         Driver      "$MODULE"
664         VendorName  "All"
665         BoardName   "All"
666         ## Workaround for drivers which send output to wrong device:
667         # Option "MonitorLayout" "LVDS, AUTO"
668         # Option "MonitorLayout" "LVDS, CRT"
669         # Option "MonitorLayout" "NONE, STV"
670         # Option "MonitorLayout" "LVDS"
671         ## Specify BusID:
672         # BusID       "PCI:1:0:0"
673 EndSection
674
675 Section "Screen"
676         Identifier "Screen0"
677         Device     "Card0"
678         Monitor    "Monitor0"
679         DefaultColorDepth 16
680         SubSection "Display"
681                 Depth     1
682                 $MODES
683         EndSubSection
684         SubSection "Display"
685                 Depth     4
686                 $MODES
687         EndSubSection
688         SubSection "Display"
689                 Depth     8
690                 $MODES
691         EndSubSection
692         SubSection "Display"
693                 Depth     15
694                 $MODES
695         EndSubSection
696         SubSection "Display"
697                 Depth     16
698                 $MODES
699         EndSubSection
700         SubSection "Display"
701                 Depth     24
702                 $MODES
703         EndSubSection
704         SubSection "Display"
705                 Depth     32
706                 $MODES
707         EndSubSection
708 EndSection
709
710 Section "DRI"
711         Mode 0666
712 EndSection
713
714 #Section "Extensions"
715 #    Option "Composite" "Enable"
716 #EndSection
717
718 ## END OF FILE #################################################################
719 EOX
720 }
721 # }}}
722
723 # writeit {{{
724 writeit() {
725     XCONFTMP="/tmp/xconfig.$$"
726     xconfig > $XCONFTMP
727     [ -f $XCONFIG ] && sudo mv -f $XCONFIG $XCONFIG.old
728     sudo mv $XCONFTMP $XCONFIG
729     sudo chown root.root $XCONFIG
730     sudo chmod 644 $XCONFIG
731 }
732 # }}}
733
734 # writeconfig {{{
735 function writeconfig
736 {
737   if [[ ! -f $XCONFIG ]] ; then
738     print -n "$bold_color$fg[blue]Creating $XCONFIG: $fg[red]"
739     writeit && print "$fg[green]done$reset_color"
740   else
741     print "$bold_color$fg[blue]Notice: $XCONFIG exists already.
742 Use the force-option (-force) to force creation.
743 $fg[red]"
744   fi
745   if [[ -n "$FORCE" ]] ; then
746     print "$bold_color$fg[blue]Force-switch or manual option(s) detected -"
747     print -n "moving eventual existing $XCONFIG to ${XCONFIG}.old: $fg[red]"
748     writeit && print "$fg[green]done$reset_color"
749   fi
750 }
751 # }}}
752
753 # runit {{{
754 function runit
755 {
756   writeconfig
757   if [ -z $NOSTART ] ; then
758     print "$reset_color"
759     if [ -x /etc/init.d/xorg-common ] ; then
760       sudo /etc/init.d/xorg-common start
761     else
762       if [ -x /etc/init.d/xfree86-common ] ; then
763         sudo /etc/init.d/xfree86-common start
764       fi
765     fi
766     print ""
767     if [ -z $DISPLAY ] ; then
768       print "$bold_color$fg[green]Now trying to run startx.$reset_color"
769       startx ~/.xinitrc -- $XOPTS
770     else
771       print "$bold_color$fg[green]Now trying to run startx on display $DISPLAY.$reset_color"
772       startx ~/.xinitrc -- :$DISPLAY $XOPTS
773     fi
774   else
775     print "$bold_color$fg[blue]Not running startx as requested as option.$reset_color"
776   fi
777   return 1
778 }
779 # }}}
780
781 # failed {{{
782 function failed
783 {
784   print "$fg[red]"
785   if [ $UID != 0 ] ; then
786     if [[ $(tty) == /dev/pts/* ]] ; then
787       print "It seems you are running $PROGRAMNAME from inside GNU screen.
788 Notice that this might fail if running as user grml!
789 Please exit screen and try to run $PROGRAMNAME again."
790     fi
791   fi
792   print "
793 Problems? Run the following commands for getting information on your hardware:
794   hwinfo --gfxcard
795   discover -v --data-path=xfree86/server/device/driver display
796   xdebconfigurator -c -d -i -x
797   get-edid | parse-edid
798
799 Do you want to go the debian way of life? Run:
800   apt-get install x-window-system-core read-edid mdetect hwinfo xdebconfigurator
801   dpkg-reconfigure x-window-system-core (or xserver-xfree86 or xserver-xorg depending on your system)
802
803 Problems with the module used for X? Try to load another one or
804 fall back to module vesa:
805   $PROGRAMNAME -module radeon ...
806   $PROGRAMNAME -module vesa  ...
807
808 Do you want to deactivate a present synaptics touchpad? Run:
809   $PROGRAMNAME -nosynaptics ...
810
811 Your monitor is very old and/or does not support DDC-probing?
812   $PROGRAMNAME -noddc ...
813
814 Do you want to create a x configuration file but do not start X?
815   $PROGRAMNAME -nostart ...
816
817 Monitor frequency too high or too low? Just specify hsync/vsync manually:
818   $PROGRAMNAME -hsync 30-65 ...
819   $PROGRAMNAME -hsync 30-65 -vsync 50-60 ...
820
821 Want to adjust the resolution? Use the mode-switch:
822   $PROGRAMNAME -mode 1024x768 ...
823   $PROGRAMNAME -mode '1280x1024 1024x768' ...
824
825 To adjust resolution while running X execute:
826   xrandr -s '1024x768'
827
828 More information on grml-x can be found in the manual page: man grml-x
829
830 Report bugs, send wishes and feedback to the grml team:
831 http://grml.org/bugs/ - contact (at) grml.org
832 "
833 print -n "$reset_color"
834 }
835 # }}}
836
837 # cleanup {{{
838 cleanup()
839 {
840   rm -f $HWINFO_TMP
841   rm -f $MONITORINFO
842   rm -f $MOUSEINFO
843   rm -f $XCONFTMP
844 }
845 cleanup
846 # }}}
847
848 # xinitrc {{{
849   if [ -w $XINITRC ] ; then
850     sed -i "s|^[^#]*exec.*|  exec $WINDOWMANAGER|g" $XINITRC
851     runit || failed
852   else
853     echo -e "#!/bin/sh\n  exec $WINDOWMANAGER" >> $XINITRC
854     runit || failed
855   fi
856 # }}}
857
858 ## END OF FILE #################################################################
859 # vim:foldmethod=marker