LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2157|回复: 13

本人制作的XF86Config文件自动设定程序for all linux

[复制链接]
发表于 2003-7-22 10:05:47 | 显示全部楼层 |阅读模式
说明:这是一个XFree86 Server 配置文件XF86Config的设定程序。运行界面一目了然,易于配置。经测试可在Redhat linux、mandrake linux、slackware linux等安装并成功设定。可在ttyX shell(不能在X下执行)终端执行:
hamigua-xf4config
这时会自动检测你是否运行在X的终端环境下或存在X进程的ttyX终端。如果有,则会提示你是否杀死这些进程,如果选"Yes",则先把你需要保存的内容保存好,按"Yes"后能自动退出所有的X进程。退出X后请再次运行"hamigua-xf4config"再进一步进行配置。当然如果没有X进程,则会直接进入XF86Config的配置程序。
这时选择"Yes"直接进入,一般鼠标(mouse)、键盘(keyboard)、显卡(card)均能正常检测出来。我们要做的就是要选择适合自已的屏幕分辨率及顔色,这样可设定:
选择"Configure screen"--->"Edit Sreen0",这里选择顔色,一般选24bits,16Mb colors(默认的不是这样),接下来就是先择屏幕分辨率了,这里你可选择一种,也可选择多种,如果是多种的话,在进入X之后要按"Ctrl+Alt+'+'"或"Ctrl+Alt+'-'"可切换屏幕分辨率之后自动进入X.
最后选择"Write XF86Config and quit"即可。
下载:http://www.linuxsir.cn/postnuke/ ... eq=getit&lid=35
安装:
tar zvfx hamigua-xf4config.tar.gz
rpm -ivh hamigua-xf4config-1.0-1.i386.rpm
有问题请到http://www.linuxsir.cn 发贴或发电子邮件:hamigua@8bb8.com
发表于 2003-7-22 14:12:34 | 显示全部楼层
兄弟有没有代码啊,可以读一读吗?
 楼主| 发表于 2003-7-22 21:29:47 | 显示全部楼层

这就是hamigua-xf4config shell脚本程序,调用xf86cfg

#!/bin/sh
HOME=/root

# If we aren't root, bail:
if [ "$USER" = "root" ]; then
  TMP=/var/log/setup/tmp
else
  echo "Only root can configure X."
  exit
fi

# Now, this wouldn't make much sense either:
if [ ! -r /usr/X11R6/bin/XFree86 ]; then
  exit
fi

dialog --title "CONFIGURE X SERVER?" --yesno \
"If you like, XFree86 can attempt to probe for your video hardware and mouse, and \
write an initial configuration file to /etc/X11/XF86Config.    Would you like to do this now ?       \
You can reach http://www.linuxsir.cn explore even more help. \
Establish by hamigua <hamigua@8bb8.com>" 9 66
if [ ! $? = 0 ]; then
  exit
fi

if [ ! -d $TMP ]; then
mkdir -p $TMP
chmod 700 $TMP
fi

# OK, we'll warn the user if there's already an existing XF86Config:
CONFIG_EXISTS=false
for xf86config in /etc/X11/XF86Config-4 /etc/XF86Config-4 /usr/X11R6/lib/X11/XF86Config-4 $HOME/XF86Config-4 ; do
  if [ -r $xf86config ]; then
    CONFIG_EXISTS=$xf86config
  fi  
done
if [ ! "$CONFIG_EXISTS" = "false" ]; then
  dialog --title "FOUND EXISTING XF86Config in `dirname $CONFIG_EXISTS`" \
  --msgbox "A previous X Window System configuration file has been found. \
You can now reconfigure X, replacing the file with a new version (and \
keeping a backup of the old file), or you can abort leaving the existing \
config file in place.  Hit ENTER to rename the XF86Config file to \
XF86Config.backup and create a new one, or ESC to abort." 9 72
  if [ ! $? = 0 ]; then
    exit
  fi
fi

# Have the X server create a default config file:
/usr/X11R6/bin/XFree86 -configure
if [ ! $? = 0 ]; then
  # failure, bail.
  exit
fi

# Move any existing config file(s) aside:
for xf86config in /etc/X11/XF86Config-4 /etc/XF86Config-4 /usr/X11R6/lib/X11/XF86Config-4 $HOME/XF86Config-4 ; do
  if [ -r $xf86config ]; then
    mv $xf86config ${xf86config}.backup
  fi  
done

mv $HOME/XF86Config.new /etc/X11/XF86Config
# Okay now we edit the little bugger to make it more usable
xf86cfg -textmode

# I know this completely hoses the indentation of the XF86Config file, but
# really don't know a good way around that.  Shoulda used perl.  ;)

cat /etc/X11/XF86Config | while read LINE ; do
  echo "$LINE" >> /etc/X11/XF86Config-4
  if echo $LINE | grep Load | grep type1 1> /dev/null ; then
    # X -configure is pretty broken... it leaves out the type1 and freetype
    # modules.  We'll work around this.  BTW, it matters not if these appear
    # multiple times, but matters A LOT if they don't appear at all.
    # echo "Load  \"type1\"" >> /etc/X11/XF86Config-4
    echo "Load  \"xtt\"" >> /etc/X11/XF86Config-4
  fi
# lets add wheel mouse support won't hurt if no wheel
    if echo $LINE | grep Option | grep Device | grep /dev/mouse 1> /dev/null ; then
        echo "Option      \"ZAxisMapping\"  \"4 5\"" >> /etc/X11/XF86Config-4
      fi
#All right no we add a couple more font paths and we are there
if echo $LINE | grep "/usr/X11R6/lib/X11/fonts/100dpi/" 1> /dev/null ; then
echo "FontPath     \"/usr/X11R6/lib/X11/fonts/TTF/\"" >> /etc/X11/XF86Config-4
echo "FontPath     \"/usr/X11R6/lib/X11/fonts/local/\"" >> /etc/X11/XF86Config-4
echo "FontPath     \"/usr/share/fonts/local/\"" >> /etc/X11/XF86Config-4
fi
#now lets add some monitor stuff
if echo $LINE | grep Section |grep Monitor 1> /dev/null ; then
ddcprobe  |grep "horizontal =" |sed 's%Timing ranges: horizontal =%HorizSync      %' |sed 's%, vertical =%        VertRefresh    %' >> /etc/X11/XF86Config-4
fi     
      
  done
rm -f $HOME/XF86Config.new
rm -f /etc/X11/XF86Config
# make it so normal users can use this config file

echo "Section \"DRI\"" >> /etc/X11/XF86Config-4
echo "        Mode 0666" >> /etc/X11/XF86Config-4
echo "EndSection" >> /etc/X11/XF86Config-4


dialog --title "XFree86 CONFIGURED" \
  --msgbox "Your new XFree86 configuration file has been saved to /etc/X11/XF86Config-4. \
You may still need to add or adjust some values in the file to achieve the desired \
results. For complete information about \
making these adjustments, please refer to \"man XF86Config\"." \
  11 66
发表于 2003-7-23 20:33:52 | 显示全部楼层
o .看样子。好象蛮好用的。。。
 楼主| 发表于 2003-7-23 22:13:26 | 显示全部楼层

第二次更新:

#!/bin/sh

HOME=/root

# If we aren't root, bail:
if [ "$USER" = "root" ]; then
  TMP=/var/log/setup/tmp
else
  echo "Only root can configure X."
  exit
fi

if ps -aA | grep "X" > /dev/null ; then
dialog --title "EXIT X SERVER?" --yesno \
"You are running the X server now,but this program can't run with it. \
I shall kill your X progress,after exit X server,please run 'xf4config' program to \
reconfigure once more. Do you want to continue ?
" 8 66
   if [ ! $? = 0 ]; then
   exit
   fi
   if ps -aA | grep "gdm-binary" > /dev/null ; then
   killall gdm-binary
   fi
   if ps -aA | grep "kdm" > /dev/null ; then
   killall kdm
   fi
   if ps -aA | grep "xdm" > /dev/null ; then
   killall xdm
   fi
   if ps -aA | grep "gnome-session" > /dev/null ; then
   killall gnome-session
   fi
   if ps -aA | grep "kdeinit" > /dev/null ; then
   killall kdeinit
   fi
   if ps -aA | grep "wmaker" > /dev/null ; then
   killall wmaker
   fi
   if ps -aA | grep "X" > /dev/null ; then
   killall X
   fi
fi

# Now, this wouldn't make much sense either:
if [ ! -r /usr/X11R6/bin/XFree86 ]; then
  exit
fi


dialog --title "CONFIGURE X SERVER?" --yesno \
"If you like, XFree86 can attempt to probe for your video hardware and mouse, and \
write an initial configuration file to /etc/X11/XF86Config.    Would you like to do this now ?       \
You can reach http://www.linuxsir.cn explore even more help. \
Establish by hamigua <hamigua@8bb8.com>" 9 66
if [ ! $? = 0 ]; then
  exit
fi

if [ ! -d $TMP ]; then
mkdir -p $TMP
chmod 700 $TMP
fi

# OK, we'll warn the user if there's already an existing XF86Config:
CONFIG_EXISTS=false
for xf86config in /etc/X11/XF86Config-4 /etc/XF86Config-4 /usr/X11R6/lib/X11/XF86Config-4 $HOME/XF86Config-4 ; do
  if [ -r $xf86config ]; then
    CONFIG_EXISTS=$xf86config
  fi  
done
if [ ! "$CONFIG_EXISTS" = "false" ]; then
  dialog --title "FOUND EXISTING XF86Config in `dirname $CONFIG_EXISTS`" \
  --msgbox "A previous X Window System configuration file has been found. \
You can now reconfigure X, replacing the file with a new version (and \
keeping a backup of the old file), or you can abort leaving the existing \
config file in place.  Hit ENTER to rename the XF86Config file to \
XF86Config.backup and create a new one, or ESC to abort." 9 72
  if [ ! $? = 0 ]; then
    exit
  fi
fi

# Have the X server create a default config file:
/usr/X11R6/bin/XFree86 -configure
if [ ! $? = 0 ]; then
  # failure, bail.
  exit
fi

# Move any existing config file(s) aside:
for xf86config in /etc/X11/XF86Config-4 /etc/XF86Config-4 /usr/X11R6/lib/X11/XF86Config-4 $HOME/XF86Config-4 ; do
  if [ -r $xf86config ]; then
    mv $xf86config ${xf86config}.backup
  fi  
done

mv $HOME/XF86Config.new /etc/X11/XF86Config
# Okay now we edit the little bugger to make it more usable
xf86cfg -textmode

# I know this completely hoses the indentation of the XF86Config file, but
# really don't know a good way around that.  Shoulda used perl.  ;)

cat /etc/X11/XF86Config | while read LINE ; do
  echo "$LINE" >> /etc/X11/XF86Config-4
  if echo $LINE | grep Load | grep type1 1> /dev/null ; then
    # X -configure is pretty broken... it leaves out the type1 and freetype
    # modules.  We'll work around this.  BTW, it matters not if these appear
    # multiple times, but matters A LOT if they don't appear at all.
    # echo "Load  \"type1\"" >> /etc/X11/XF86Config-4
    echo "Load  \"xtt\"" >> /etc/X11/XF86Config-4
  fi
# lets add wheel mouse support won't hurt if no wheel
    if echo $LINE | grep Option | grep Device | grep /dev/mouse 1> /dev/null ; then
        echo "Option      \"ZAxisMapping\"  \"4 5\"" >> /etc/X11/XF86Config-4
      fi
#All right no we add a couple more font paths and we are there
if echo $LINE | grep "/usr/X11R6/lib/X11/fonts/100dpi/" 1> /dev/null ; then
echo "FontPath     \"/usr/X11R6/lib/X11/fonts/TTF/\"" >> /etc/X11/XF86Config-4
echo "FontPath     \"/usr/X11R6/lib/X11/fonts/local/\"" >> /etc/X11/XF86Config-4
echo "FontPath     \"/usr/share/fonts/local/\"" >> /etc/X11/XF86Config-4
fi
#now lets add some monitor stuff
if echo $LINE | grep Section |grep Monitor 1> /dev/null ; then
ddcprobe  |grep "horizontal =" |sed 's%Timing ranges: horizontal =%HorizSync      %' |sed 's%, vertical =%        VertRefresh    %' >> /etc/X11/XF86Config-4
fi     
      
  done
rm -f $HOME/XF86Config.new
rm -f /etc/X11/XF86Config
# make it so normal users can use this config file

echo "Section \"DRI\"" >> /etc/X11/XF86Config-4
echo "        Mode 0666" >> /etc/X11/XF86Config-4
echo "EndSection" >> /etc/X11/XF86Config-4


dialog --title "XFree86 CONFIGURED" \
  --msgbox "Your new XFree86 configuration file has been saved to /etc/X11/XF86Config-4. \
You may still need to add or adjust some values in the file to achieve the desired \
results. For complete information about \
making these adjustments, please refer to. \"man XF86Config\" I'll go on X server now." \
  11 66
gdm
发表于 2003-7-24 19:55:12 | 显示全部楼层
ddcprobe??
我在debian上没有找到这个程序。

读了一遍程序代码,有些疑问
你这个会不会出现Load "type1"跟Load "xtt"同时存在的情况?
还有你对XF86config-4的检测,是不是要加入一项,如果程序找不到,手工指定的?(好像实际意义不大).
发表于 2003-7-28 10:32:36 | 显示全部楼层
同时用 "load Xtt" 和 “load type1" 会出什么严重问题吗?
发表于 2003-7-28 10:46:31 | 显示全部楼层
我就是同时load xtt & freetype & type1
好像没有什么问题耶
发表于 2003-7-28 10:54:15 | 显示全部楼层
It can be used in Gentoo Linux????
发表于 2003-7-28 16:17:59 | 显示全部楼层
好像在debian上,同时使用freetype or type1 && xtt会启动不了x.
现在在windows没法试
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表