autoX - autoconfigure X server

Some scripts, tip and tricks, porting Slackware. In summary: how to destroy a good Slackware !

autoX - autoconfigure X server

Postby fabius » Sat Oct 03, 2009 2:33 pm

New Xorg Server 1.6.3 works with HAL and detect peripheral automatically ... so xorg.conf is unnecessary ...

with HAL disabled may be useful a script to create a suitable xorg.conf ... this is the code of script autoX:
Code: Select all
#!/bin/sh
# autoX - autodetect xorg.conf
#         Copyleft (!c) FZ 2005-2009

autoX_version='4.2.1 - 03/10/2009  FZ'
# Note: this version disable HAL support in Xorg ServerFlags Section


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 screens, hdtv screens
#X_SCREEN_MODES='"1600x1200" "1280x1024" "1024x768"' #4/3 screens

#---------- text color echo ---------
function echoc()
{
case "$2" in
black)
  echo "$1"
;;
red)
  echo "$1"
;;
green)
  echo "$1"
;;
yellow)
  echo "$1"
;;
blue)
  echo "$1"
;;
magenta)
  echo "$1"
;;
cyan)
  echo "$1"
;;
white)
  echo "$1"
;;
*)
  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

X -configure 2> /dev/null

# 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`

SECTION_DEVICE=`echo $SECTION_DEVICE | sed -n '/"Card0"/,/EndSection/p' /dev/stdin | 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 '  Option   "AllowEmptyInput"     "false"' >> $Xcfg_out
echo '  Option   "AutoAddDevices"      "false"' >> $Xcfg_out
echo '  Option   "AutoEnableDevices"   "false"' >> $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 '  Load "synaptics"'    >> $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
(to copy and paste code don't use "Select All" function, but mouse drag selection)

to exec:
Code: Select all
# ./autoX


Download the script:
autoX-4.2.1.tar.gz
autoX v.4.2.1 - autoconfigure X with HAL disabled
(3.29 KiB) Downloaded 714 times


it works (I hope ...) :geek:
fabius
 
Posts: 6
Joined: Sun Sep 20, 2009 11:41 am

Re: autoX - autoconfigure X server

Postby zoros » Sat Oct 03, 2009 8:03 pm

autoX works fine in Slackware 13 8-) ... but we can disable both hal and messagebus daemons ...

to try only one time:
Code: Select all
/etc/rc.d/rc.hald stop
/etc/rc.d/rc.messagebus stop


to reset permanently HAL:
Code: Select all
chmod 644 /etc/rc.d/rc.hald
chmod 644 /etc/rc.d/rc.messagebus


;)
User avatar
zoros
Site Admin
 
Posts: 22
Joined: Thu Mar 12, 2009 9:16 am


Return to BiSlack - Porting Slackware®

Who is online

Users browsing this forum: No registered users and 1 guest

cron