xinitrc---多个窗口管理器

系统安装、升级讨论
版面规则
我们都知道新人的确很菜,也喜欢抱怨,并且带有浓厚的Windows习惯,但既然在这里询问,我们就应该有责任帮助他们解决问题,而不是直接泼冷水、简单的否定或发表对解决问题没有任何帮助的帖子。乐于分享,以人为本,这正是Ubuntu的精神所在。
回复
onelynx
帖子: 817
注册时间: 2008-11-13 16:03

xinitrc---多个窗口管理器

#1

帖子 onelynx » 2009-10-27 16:26

Switching Between Window Managers and Desktop Environments
18-Feb-2001
Stefan Jeglinski

Linux distributions typically include desktop environments like KDE and/or Gnome, and window managers like Afterstep, Blackbox, Ice, and/or WindowMaker. Each distribution sets a default, and each environment or manager has its advocates and detractors. Desktop environments like Gnome and KDE are generally slower than lean window managers like Blackbox or Ice.

* the key is .xinitrc
* the original R4 page
* return to the home page

the key is .xinitrc

* The ~/.xinitrc file is run at the X startup. If no ~/.xinitrc file exists (typically true after the initial Linux install), a default version (/etc/X11/xinit/xinitrc) is run. ~/.xinitrc commonly calls ~/.Xclients as part of the process but this is not inherently required and appears to be convention more than anything. ~/.xinitrc can exist without ~/.Xclients but not the other way around. ~/.xinitrc can be easily configured to select between desktop environments, or a variety of window managers as follows:


#!/bin/sh

########################################################################
# .xinitrc #
# 5/22/00 Stefan Jeglinski, jeglin@rapierbit.org #
# based on one written by hollis+@andrew.cmu.edu 1/5/99 #
# Thanks Hollis! #
# #
# To use: #
# * if you have a ~/.Xclients, remove it. The system copy is in #
# /etc/X11/xinit/Xclients if you ever want it back. #
# #
# * place this file in your home (~) directory. For root, #
# home is /root. #
# #
# * Type 'startx after', 'startx kde', etc. #
# #
########################################################################

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
xclients=$HOME/.Xclients
sysresources=/usr/X11R6/lib/X11/xinit/.Xresources
sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
xmodmap $sysmodmap
fi

if [ -f $userresources ]; then
xrdb -merge $userresources
fi

if [ -f $usermodmap ]; then
xmodmap $usermodmap
fi

########################################################################
# #
# to fix backspace and delete in X if necessary; #
# these may need to be removed for XFree86 4.x #
# #
########################################################################
xmodmap -e "keycode 59 = BackSpace"
xmodmap -e "keycode 125 = Delete"

########################################################################
# #
# accelerate the mouse in the window manager; #
# Gnome and KDE typically override this #
# #
########################################################################
xset m 8 3

########################################################################
# #
# define mouse button usage in the window manager; #
# this directive may be "eaten" by the Gnome or KDE startup #
# and may therefore need to be run again after the environment #
# is started #
# #
########################################################################
xmodmap -e "pointer = 2 1 3"

########################################################################
# #
# * Set variables for different window managers and environments #
# #
# * $1 represents the first argument to startx. #
# #
# * WM is the name of the program to execute. This is normally the #
# window manager itself, but in the case of kde or gnome it needs #
# to be the gnome-session or startkde script. #
# #
########################################################################

ARG=$1

# specify the default argument here:
DEFAULTWM="gnome-session"

if [ ! $ARG ]; then
ARG=$DEFAULTWM
fi

########################################################################
# #
# The difference between a desktop environment and a window manager #
# is that an environment provides a desktop, while a window manager #
# just handles the window dressing. An environment needs a WM, but #
# not vice versa. The only 2 environments are Gnome and KDE. Common #
# window managers for Gnome are Sawfish and Enlightenment. KDE #
# has its own window manager (kwm). #
# #
########################################################################

# to add another wm/environment here, just copy, paste,
# and edit the 'elif' line:

if [ $ARG = "gnome" ]; then
WM=gnome-session
elif [ $ARG = "kde" ]; then
WM=startkde
elif [ $ARG = "after" ]; then
WM=afterstep
elif [ $ARG = "wm" ]; then
WM=wmaker
elif [ $ARG = "en" ]; then
WM=enlightenment
elif [ $ARG = "bb" ]; then
WM=blackbox
elif [ $ARG = "ice" ]; then
WM=icewm
else
WM=$DEFAULTWM
fi

########################################################################
# #
# set a background window color for window managers only; #
# if an environment starts up, it will override this #
# #
########################################################################
xsetroot -solid MidnightBlue

########################################################################
# #
# don't turn on screen-saver for window manager #
# #
########################################################################
#xset s on

########################################################################
# #
# turn on a REAL screensaver, http://www.jwz.org/xscreensaver/ #
# #
########################################################################
xhost +localhost
xscreensaver &
xscreensaver-command -activate

########################################################################
# #
# The next line actually runs the selected window manager and logs #
# the output (stdout AND stderr) to the file ~/console. If you run a #
# #
# tail -f ~/console #
# #
# in an xterm, it will display the (constantly updated) contents of #
# that file. This can be usful for talk requests, wm errors, etc. #
# #
########################################################################

exec $WM >& ~/console


* With this .xinitrc, from bash, just run startx gnome, startx kde, startx after, etc. If a mistake is made in typing, Gnome will be launched because it's the default. Make sure of course that the window manager or environment you are trying to run is installed!

* If you are running XFree86, check out the XFree86 page for more information. If you are running Xpmac, arguments can be passed to set monitor resolution. These arguments cannot be passed in .xinitrc, but they can easily be added as an alias; to do this, add the following example aliases to .bashrc:


alias sa='startx after -- -mode 16 -depth 16'
alias sk='startx kde -- -mode 16 -depth 16'
alias sg='startx -- -mode 16 -depth 16'


then just type sa, sk, or sg from the command line.

* A desktop environment (for example, startkde) cannot be launched directly from the console, because the X server will not have been launched. The instructions in .xinitrc are only run after the X server starts, and for that startx must be used to begin the process.


原文地址:http://www.rapierbit.org/linux/winmgrs.html
头像
nmsfan
帖子: 18958
注册时间: 2009-10-16 22:46
来自: finland

Re: xinitrc---多个窗口管理器

#2

帖子 nmsfan » 2009-10-27 17:38

晕,没汉字 :em20
>>>>推Ubuntu 桌面培训~~<<<<
>>>>想加入/了解gimp汉化吗,点我吧~<<<<
——————————————————————
不推荐wubi,也不推荐你给别人推荐wubi…………
随心而为的感觉真好……
强推mayhem!!
强推ensiferum
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: xinitrc---多个窗口管理器

#4

帖子 eexpress » 2009-10-27 19:46

这,确实是折腾了。 :em04
● 鸣学
onelynx
帖子: 817
注册时间: 2008-11-13 16:03

Re: xinitrc---多个窗口管理器

#5

帖子 onelynx » 2009-10-27 20:27

nmsfan 写了:晕,没汉字 :em20

脚本要汉字干砸

不折疼的话,就没必要了,要折腾的话,没汉字也明白的
回复