调整startx的默认设置

[手动搬家自网易博客 原发表日期:2008-03-23]         在学校,我为了追求效率,便在magiclinux 2.1上安装了轻量级的xfce4桌面,默认运行级别为3。但每次要进入桌面时,如果用startx就会进入KDE,用startxfce4进入 xfce4后又是英文界面,而且无法使用中文输入法。今天我突然发现,startx实际上是一个脚本,然后用vim打开后逐行阅读、跟踪,最后终于发现默 认的桌面设置在/etc/sysconfig/desktop和/etc/X11/xinit/Xclients这两个文件中。然后修改了这两个文件,终 于可以用startx正常进入xfce4了。 附:现在我的这两个文件: /etc/sysconfig/desktop: DESKTOP=XFCE4 DISPLAYMANAGER=XFCE4 # DESKTOP=KDE # DISPLAYMANAGER=KDE /etc/X11/xinit/Xclients:
#!/bin/bash
# Copyright (C) 1999 - 2004 Red Hat, Inc. All rights reserved. This
# copyrighted material is made available to anyone wishing to use, modify,
# copy, or redistribute it subject to the terms and conditions of the
# GNU General Public License version 2.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

GSESSION="$(which gnome-session 2>/dev/null)"
STARTKDE="$(which startkde 2>/dev/null)"
STARTXFCE4="$(which startxfce4 2>/dev/null)"

# check to see if the user has a preferred desktop
PREFERRED=
if [ -f /etc/sysconfig/desktop ]; then
    . /etc/sysconfig/desktop
    if [ "$DESKTOP" = "KDE" ]; then
 PREFERRED="$STARTKDE"
    elif [ "$DESKTOP" = "GNOME" ]; then
 PREFERRED="$GSESSION"
    elif [ "$DESKTOP" = "XFCE4" ]; then
 PREFERRED="$STARTXFCE4"
    fi
fi

if [ -n "$PREFERRED" ]; then
    exec "$PREFERRED"
fi

# now if we can reach here, either no desktop file was present,
# or the desktop requested is not installed.

if [ -n "$STARTXFCE4" ]; then
    # by default, we run XFCE4.
    exec "$STARTXFCE4"
elif [ -n "$STARTKDE" ]; then
    # if XFCE4 isn't installed, try KDE.
    exec "$STARTKDE"
elif [ -n "$GSESSION" ]; then
    # if XFCE4 isn't installed, try GNOME.
    exec "$GSESSION"
fi

# Failsafe.

# these files are left sitting around by TheNextLevel.
rm -f $HOME/Xrootenv.0

# Argh! Nothing good is installed. Fall back to twm
{
    # gosh, neither fvwm95 nor fvwm2 is available; 
    # fall back to failsafe settings
    if which xclock &>/dev/null ; then
  xclock -geometry 100x100-5+5 &
    fi
    if which xterm &>/dev/null ; then
        xterm -geometry 80x50-50+150 &
    fi
    if which twm &>/dev/null ; then
 exec twm
    fi
}

你可能感兴趣的:(脚本,user,File,vim,输入法,网易)