编辑 /usr/X11/bin/startx,在下面语句:
whoseargs="client"
while [ "x$1" != "x" ]; do
case "$1" in
/@#@#*|\.*) if [ "$whoseargs" = "client" ]; then
clientargs="$1"
else
serverargs="$1"
fi ;;
--) whoseargs="server" ;;
*) if [ "$whoseargs" = "client" ]; then
clientargs="$clientargs $1"
else
serverargs="$serverargs $1"
fi ;;
esac
shift
done
xinit $clientargs -- $serverargs
之前的任一空处(不要写在控制语句块内和程序开头)插入以下语句:
case "$1" in
"kde") if [ -r "/etc/X11/xinit/Xclients.kde" ]; then
cp /etc/X11/xinit/Xclients.kde $HOME/.Xclients
fi ;;
"mwm") if [ -r "/etc/X11/mwm/Xclients" ]; then
cp /etc/X11/mwm/Xclients $HOME/.Xclients
fi ;;
"twm") if [ -r "/etc/X11/twm/Xclients" ]; then
cp /etc/X11/twm/Xclients $HOME/.Xclients
fi ;;
*) if [ -r "/etc/X11/xinit/Xclients" ]; then
cp /etc/X11/xinit/Xclients $HOME/.Xclients
fi ;;
esac
上面用到的 /etc/X11/twm/Xclients 程序是笔者为启动 twm 编写的,内容如下:
#!/bin/bash
xpmroot /usr/X11R6/include/X11/pixmaps/rhpenguin.xpm
xterm -title "Hello,welcome to twm!" &
exec twm
仿照这个 Xclients 程序可以编写未提供 Xclients 的其它窗口管理器的Xclients 程序。
根据具体情况修改、增加 case 选项即可满足不同需要。
修改后程序的运行方法为:startx [ kde | mwm | twm ],例如:运行startx kde 命令即可启动 kde,运行不带参数的 startx 命令启动系统默认的fvwm95。
---- 以上程序在 RedHat Linux 5.1 中运行通过。
延伸阅读
文章来源于领测软件测试网 https://www.ltesting.net/










