调整startx的默认设置

本文介绍如何在MagicLinux 2.1系统中配置轻量级的XFCE4桌面环境,解决启动时默认进入KDE及无法使用中文输入法的问题。通过修改配置文件/etc/sysconfig/desktop和/etc/X11/xinit/Xclients,实现使用startx命令直接启动XFCE4。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[手动搬家自网易博客 原发表日期: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
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值