al di la dello script che è nato in un certo modo e non ho il tempo per renderlo "elegante" a me preme far passare alcune idee/osservazioni:
1) esiste già un "X -configure" e le ultime versioni di Xorg generano un xorg.conf abbastanza buono ... ma non ci siamo ancora, non è ancora ok ...
2) il problema di far partire un X decente (o semplicemente di farlo partire) si ripresenta ancora troppe volte ... non avere la grafica per un newbie è un dramma, la grafica deve partire ... se poi l'installazione si sposta (tipo disco usb) allora un autoX è molto utile ...
in attesa quindi che questo "X -configure" ufficiale sia al 100% con uno script possiamo rimediare ai punti di incertezza del programma ... i punti che ho rilevato sono questi:
1) la risoluzione scelta non è sempre quella ottimale, in particolare se abbiamo monitor wide-screen
2) se il monitor non è collegato il DDC non funziona e ci "becchiamo" un 640x480 ... impossibile da usare
3) non vengono aggiunte le poche "option" che servono per usare un compiz o beryl
4) se sono stati installati driver proprietari ATI e nVidia questi non vengono rilevati correttamente, anzi per le nVidia ci viene proposto un driver "vga" che poi neanche parte
5) in altri casi viene proposto il driver "vga" quando ormai tutte le schede grafiche sono in grado di sostenere il "vesa" ...
lo script proposto parte da "X -configure" e aggiusta alcune cose ricreando /etc/X11/xorg.conf ... lo script è in grado di funzionare così com'è in qualsiasi path anche se avevo previsto una directory specifica (/etc/biSlack) dove creare un file "Config" per eventuali customizzazioni ... può essere richiamato in rc.local o rc.4 così partirà ad ogni avvio ...
Codice: Seleziona tutto
#!/bin/sh
# autoX - autodetect xorg.conf
# Copyleft (!c) FZ 2005-2009
autoX_version='4.0 - 04/24/2009 FZ'
PATH=/sbin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:/etc/biSlack
CUSTOM_CONFIG=/etc/biSlack/Config
#--- here you can customize some xorg options --------
# you can put this parameters in a $CUSTOM_CONFIG file
#MONITOR=auto # low,medium,high,auto
#X_COLOR_DEPTH=24 # 8,16,24
#LAYOUT=it #to force keyboard layout
#XFS_REMOTE_SERVER=192.168.1.123 #to use a remote font server
#X_SCREEN_MODES='"1920x1080" "1366x768" "1280x800"' #wide screen, hdtv screen
#X_SCREEN_MODES='"1600x1200" "1280x1024" "1024x768"' #4/3 screen
#---------- text color echo ---------
function echoc()
{
case "$2" in
black)
echo "[01;30m$1[00m"
;;
red)
echo "[01;31m$1[00m"
;;
green)
echo "[01;32m$1[00m"
;;
yellow)
echo "[01;33m$1[00m"
;;
blue)
echo "[01;34m$1[00m"
;;
magenta)
echo "[01;35m$1[00m"
;;
cyan)
echo "[01;36m$1[00m"
;;
white)
echo "[01;37m$1[00m"
;;
*)
echo "$1"
;;
esac
}
#------------------------------------
# Loading some custom xorg parameters
if [ -f $CUSTOM_CONFIG ] ; then
. $CUSTOM_CONFIG
fi
# if exist file no_detect_video then exit
if [ -e /etc/biSlack/no_detect_video ] ; then
echoc " Custom xorg.conf ... exit" red
exit
fi
Xcfg_file=xorg.conf
Xcfg_out=/etc/X11/$Xcfg_file
Xcfg_new="not_detected"
if [ -a $Xcfg_out ]; then
rm -Rf $Xcfg_out.prec
cp $Xcfg_out $Xcfg_out.prec
fi
export HOME=/root
rm -f /$Xcfg_file.new
rm -f /root/$Xcfg_file.new
echoc " Detecting video ..." red
# Check your effective X server path and module path if -configure not work
if [ -d /usr/lib/xorg/modules ] ; then
X -configure -modulepath /usr/lib/xorg/modules 2> /dev/null
else
X -configure -modulepath /usr/lib/X11/modules 2> /dev/null
fi
# Search xorg.conf.new in some path
if [ -a /$Xcfg_file.new ]; then
Xcfg_new=/$Xcfg_file.new
fi
if [ -a /root/$Xcfg_file.new ]; then
Xcfg_new=/root/$Xcfg_file.new
fi
if [ -a /etc/$Xcfg_file.new ]; then
Xcfg_new=/etc/$Xcfg_file.new
fi
if [ -a /etc/X11/$Xcfg_file.new ]; then
Xcfg_new=/etc/X11/$Xcfg_file.new
fi
if [ -a /etc/init.d/$Xcfg_file.new ]; then
Xcfg_new=/etc/init.d/$Xcfg_file.new
fi
# extract detected parameters
IFS=
SECTION_DEVICE=`sed -n '/Section "Device"/,/EndSection/p' $Xcfg_new | grep -v "#" 2> /dev/null`
Driver=`echo $SECTION_DEVICE | grep Driver | cut -d'"' -f2 2> /dev/null`
VendorName=`echo $SECTION_DEVICE | grep Vendor | cut -d'"' -f2 2> /dev/null`
BoardName=`echo $SECTION_DEVICE | grep Board | cut -d'"' -f2 2> /dev/null`
BusID=`echo $SECTION_DEVICE | grep BusID | cut -d'"' -f2 2> /dev/null`
if [ -a $Xcfg_new ]; then
echoc "Vendor $VendorName" blue
echoc "Board $BoardName" blue
echoc "Driver $Driver" yellow
echoc "BusID $BusID" green
else
echoc "Not Detected try VESA" yellow
fi
USBdev=/dev/input/mice
PS2dev=/dev/psaux
echo '######################################################' > $Xcfg_out
echo "# $Xcfg_file automatically configured by autoX" >> $Xcfg_out
echo "# version $autoX_version" >> $Xcfg_out
echo '######################################################' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "ServerLayout"' >> $Xcfg_out
echo ' Identifier "Xorg Configured"' >> $Xcfg_out
echo ' Screen 0 "Screen0" 0 0' >> $Xcfg_out
echo ' InputDevice "Keyboard0" "CoreKeyboard"' >> $Xcfg_out
echo ' InputDevice "USB_Mouse" "CorePointer"' >> $Xcfg_out
echo ' InputDevice "Synaptics" "SendCoreEvents"' >> $Xcfg_out
# if you not have serial mouse comment the two following line
echo ' InputDevice "Serial_Mouse0" "SendCoreEvents"' >> $Xcfg_out
echo ' InputDevice "Serial_Mouse1" "SendCoreEvents"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "ServerFlags"' >> $Xcfg_out
echo ' AllowMouseOpenFail' >> $Xcfg_out
echo ' #DontZap' >> $Xcfg_out
echo ' #DontZoom ' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "Files"' >> $Xcfg_out
echo ' RgbPath "/usr/lib/X11/rgb"' >> $Xcfg_out
echo '# ModulePath "/usr/X11R6/lib/modules"' >> $Xcfg_out
if [ "a$XFS_REMOTE_SERVER" != "a" ] ; then
# use external font server if defined in Config
echoc "Server IP $XFS_REMOTE_SERVER" red
echo " FontPath \"tcp/$XFS_REMOTE_SERVER:7100\"" >> $Xcfg_out
else
echo " FontPath \"unix/:-1\"" >> $Xcfg_out
fi
echo ' FontPath "/usr/share/fonts/local/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/misc/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/OTF/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/TTF/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/Type1/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/CID/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/Speedo/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/75dpi/:unscaled"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/100dpi/:unscaled"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/75dpi/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/100dpi/"' >> $Xcfg_out
echo ' FontPath "/usr/share/fonts/cyrillic/"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "Module"' >> $Xcfg_out
echo ' Load "GLcore"' >> $Xcfg_out
echo ' Load "record"' >> $Xcfg_out
echo ' Load "extmod"' >> $Xcfg_out
echo ' Load "ddc"' >> $Xcfg_out
echo ' Load "int10' >> $Xcfg_out
echo ' Load "dbe"' >> $Xcfg_out
echo ' Load "dri"' >> $Xcfg_out
echo ' Load "glx"' >> $Xcfg_out
echo ' Load "xtrap"' >> $Xcfg_out
echo ' Load "type1"' >> $Xcfg_out
echo ' Load "freetype"' >> $Xcfg_out
echo ' Load "speedo"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "DRI"' >> $Xcfg_out
echo ' Mode 0666' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
if [ "a$LAYOUT" = "a" ] ; then
LAYOUT=`echo $LANG | cut -d_ -f1`
case $LAYOUT in
"en")
LAYOUT="us"
;;
esac
fi
echoc "Keyboard $LAYOUT" gray
echo 'Section "InputDevice"' >> $Xcfg_out
echo ' Identifier "Keyboard0"' >> $Xcfg_out
echo ' Driver "kbd"' >> $Xcfg_out
echo ' Option "XkbModel" "pc105"' >> $Xcfg_out
echo ' Option "XkbLayout" "'$LAYOUT'"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "InputDevice"' >> $Xcfg_out
echo ' Identifier "PS2_Mouse"' >> $Xcfg_out
echo ' Driver "mouse"' >> $Xcfg_out
if [ "a$DeviceType" = "aintellimouse" ] ; then
echo ' Option "Protocol" "IMPS/2"' >> $Xcfg_out
else
echo ' Option "Protocol" "PS/2"' >> $Xcfg_out
fi
echo ' Option "Device" "'$PS2dev'"' >> $Xcfg_out
echo ' Option "Buttons" "5"' >> $Xcfg_out
echo ' Option "ZAxisMapping" "4 5"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "InputDevice"' >> $Xcfg_out
echo ' Identifier "USB_Mouse"' >> $Xcfg_out
echo ' Driver "mouse"' >> $Xcfg_out
echo ' Option "Protocol" "IMPS/2"' >> $Xcfg_out
echo ' Option "Device" "'$USBdev'"' >> $Xcfg_out
echo ' Option "Buttons" "5"' >> $Xcfg_out
echo ' Option "ZAxisMapping" "4 5"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "InputDevice"' >> $Xcfg_out
echo ' Identifier "Synaptics"' >> $Xcfg_out
echo ' Driver "synaptics"' >> $Xcfg_out
echo ' Option "SendCoreEvents" "true"' >> $Xcfg_out
echo ' Option "Device" "'$PS2dev'"' >> $Xcfg_out
echo ' Option "Protocol" "auto-dev"' >> $Xcfg_out
echo ' Option "HorizScrollDelta" "0"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "InputDevice"' >> $Xcfg_out
echo ' Identifier "Serial_Mouse0"' >> $Xcfg_out
echo ' Driver "mouse"' >> $Xcfg_out
echo ' Option "Protocol" "Microsoft"' >> $Xcfg_out
echo ' Option "Device" "/dev/ttyS0"' >> $Xcfg_out
echo ' Option "Emulate3Buttons"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "InputDevice"' >> $Xcfg_out
echo ' Identifier "Serial_Mouse1"' >> $Xcfg_out
echo ' Driver "mouse"' >> $Xcfg_out
echo ' Option "Protocol" "Microsoft"' >> $Xcfg_out
echo ' Option "Device" "/dev/ttyS1"' >> $Xcfg_out
echo ' Option "Emulate3Buttons"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "Monitor"' >> $Xcfg_out
echo ' Identifier "Monitor0"' >> $Xcfg_out
echo ' VendorName "Monitor Vendor"' >> $Xcfg_out
echo ' ModelName "Monitor Model"' >> $Xcfg_out
if [ "a$MONITOR" = "alow" ]; then
echo ' HorizSync 31.5 - 48.5' >> $Xcfg_out
echo ' VertRefresh 50.0 - 70.0' >> $Xcfg_out
fi
if [ "a$MONITOR" = "amedium" ]; then
echo ' HorizSync 24.0 - 80.0' >> $Xcfg_out
echo ' VertRefresh 49.0 - 75.0' >> $Xcfg_out
fi
if [ "a$MONITOR" = "ahigh" ]; then
echo ' HorizSync 30.0 - 64.0' >> $Xcfg_out
echo ' VertRefresh 40.0 - 90.0' >> $Xcfg_out
fi
if [ "a$MONITOR" = "a" ] || [ "a$MONITOR" = "aauto" ] ; then
ok_DDC_Monitor=`cat /var/log/Xorg.0.log | grep "DDC read successfully"`
if [ "a$ok_DDC_Monitor" = "a" ] ; then
echo ' HorizSync 31.5 - 48.5' >> $Xcfg_out
echo ' VertRefresh 50.0 - 70.0' >> $Xcfg_out
else
echo '# HorizSync 31.5 - 48.5' >> $Xcfg_out
echo '# VertRefresh 50.0 - 70.0' >> $Xcfg_out
fi
fi
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "Device"' >> $Xcfg_out
echo ' Identifier "Card0"' >> $Xcfg_out
# Detect if libGL.so replaced vith nVidia proprietary library
if [ "a$Driver" = "anv" ] || [ "a$Driver" = "avga" ] ; then
is_nvidia_installed=`cat /usr/lib/libGL.so | grep NVIDIA 2> /dev/null`
if [ "a$is_nvidia_installed" != "a" ]; then
Driver="nvidia"
echoc "Proprietary nVidia driver: $Driver" yellow
fi
fi
# Detect if fglrx driver is installed - Check your ATI driver installation path
if [ "a$Driver" = "avesa" ] && [ -f /usr/lib/xorg/modules/drivers/fglrx_drv.so ]; then
Driver="fglrx"
echoc "Proprietary ATI driver: $Driver" yellow
fi
# some nVidia are detected as vga ... change to vesa in this cases
if [ "a$Driver" = "avga" ] ; then
Driver="vesa"
fi
if [ -a $Xcfg_new ]; then
echo " Driver \"$Driver\"" >> $Xcfg_out
echo " VendorName \"$VendorName\"" >> $Xcfg_out
echo " BoardName \"$BoardName\"" >> $Xcfg_out
echo " BusID \"$BusID\"" >> $Xcfg_out
if [ "a$BoardName" = "aET6000" ]; then
echo " videoram 2048" >> $Xcfg_out
fi
else
echo ' Driver "vesa"' >> $Xcfg_out
echo ' VendorName "All Vendors"' >> $Xcfg_out
echo ' BoardName "Vesa Generic"' >> $Xcfg_out
echo ' ChipSet "vesa"' >> $Xcfg_out
echo ' Card "vesa vesa"' >> $Xcfg_out
fi
echo " Option \"ColorTiling\" \"On\"" >> $Xcfg_out
echo " Option \"EnablePageFlip\" \"True\"" >> $Xcfg_out
echo " Option \"AccelMethod\" \"XAA\"" >> $Xcfg_out
echo " Option \"XAANoOffscreenPixmaps\" \"True\"" >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "Screen"' >> $Xcfg_out
echo ' Identifier "Screen0"' >> $Xcfg_out
echo ' Device "Card0"' >> $Xcfg_out
echo ' Monitor "Monitor0"' >> $Xcfg_out
if [ "a$X_COLOR_DEPTH" != "a" ]; then
echo " DefaultDepth $X_COLOR_DEPTH" >> $Xcfg_out
else
echo ' DefaultDepth 24' >> $Xcfg_out
fi
echo ' Option "RenderAccel" "True"' >> $Xcfg_out
echo ' Option "AllowGLXWithComposite" "True"' >> $Xcfg_out
echo ' Option "AddARGBGLXVisuals" "True"' >> $Xcfg_out
echo '# Option "XAANoOffscreenPixmaps" "True"' >> $Xcfg_out
if [ "a$X_SCREEN_MODES" != "a" ]; then
MODES_=$X_SCREEN_MODES
else
MODES_='"1366x768" "1280x800" "1280x1024" "1024x768" "800x600"'
fi
echo ' SubSection "Display"' >> $Xcfg_out
echo ' Depth 1' >> $Xcfg_out
echo " Modes $MODES_" >> $Xcfg_out
echo ' EndSubSection' >> $Xcfg_out
echo ' SubSection "Display"' >> $Xcfg_out
echo ' Depth 4' >> $Xcfg_out
echo " Modes $MODES_" >> $Xcfg_out
echo ' EndSubSection' >> $Xcfg_out
echo ' SubSection "Display"' >> $Xcfg_out
echo ' Depth 8' >> $Xcfg_out
echo " Modes $MODES_" >> $Xcfg_out
echo ' EndSubSection' >> $Xcfg_out
echo ' SubSection "Display"' >> $Xcfg_out
echo ' Depth 15' >> $Xcfg_out
echo " Modes $MODES_" >> $Xcfg_out
echo ' EndSubSection' >> $Xcfg_out
echo ' SubSection "Display"' >> $Xcfg_out
echo ' Depth 16' >> $Xcfg_out
echo " Modes $MODES_" >> $Xcfg_out
echo ' EndSubSection' >> $Xcfg_out
echo ' SubSection "Display"' >> $Xcfg_out
echo ' Depth 24' >> $Xcfg_out
echo " Modes $MODES_" >> $Xcfg_out
echo ' EndSubSection' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out
echo 'Section "Extensions"' >> $Xcfg_out
echo ' Option "Composite" "Enable"' >> $Xcfg_out
echo 'EndSection' >> $Xcfg_out
echo '' >> $Xcfg_out