Xinit (简体中文)

From ArchWiki
Revision as of 16:54, 8 July 2009 by GD (talk | contribs) (added {{translateme}})
Jump to navigation Jump to search

Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Xinit (简体中文)#)

Template:I18n links start Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n entry Template:I18n links end

xinit用来启动的X Window系统服务器和系统中第一个客户端程序,它们不能直接从/etc/init启动或用于多头显示的环境。因此.xinitrc文件是一种通常与直接从inittab运行startx脚本结合使用的启动X的简单方法。

工作原理

The .xinitrc file is really just one more shell script to run. It can be used to start various applications you want to associate with starting X, e.g. the X screensaver, and to set global environment variables, like MOZ_PLUGIN_PATH. It's foremost use however, is as a replacement for a display manager when on a single user machine. When you do not start a display manager it is important to keep in mind that the life of your X session starts and ends with the .xinitrc script. What this means is that once the script finishes, X quits, regardless of whether you still have running programs, including your window manager. It is therefore important that the window manager quitting and X quitting should coincide. This is usually achieved by running the window manager as the last thing in the .xinitrc script, e.g.

/usr/bin/xscreensaver -no-splash &
/usr/lib/notification-daemon/notification-daemon &
export MOZ_PLUGIN_PATH="/usr/lib/mozilla/plugins:/opt/mozilla/lib/plugins"
exec openbox-session

Notice that the screensaver and the notification daemon are run in the background. Otherwise the script would halt and wait for the screensaver program to quit before continuing. The variable export line will run and quit very quickly. The line starting Openbox, however is not backgrounded. This ensures that the script will not quit until Openbox does. If you run the startx script manually ending the script will terminate x and leave you with whatever VCs your inittab has started. If you're running it from inittab and has set the line to 'respawn' (rather than 'once'), xinitrc will be run again. This way you can restart X without having to restart the computer.

一个标准的.xinitrc

使用这个模板时你可简单地取消注释你喜欢的,例如 Gnome

#!/bin/sh
#
# ~~/.xinitrc
#
# 被startx执行 (从这里运行你的窗口管理器)
#
# exec ion
# exec wmaker
# exec startkde
# exec icewm
# exec blackbox
exec gnome-session
# exec startfluxbox
# exec startxfce4
# exec openbox
# exec startlxde

多头显示

命令行下的技巧

如果你有一个可用的.xinitrc文件,但只想尝试下其他的窗口管理器/桌面环境,你可从命令行这样运行xinit

 xinit /full/path/to/window-manager

需要使用完整路径。此外你可以在'--'后面向X服务器传递参数,例如

 xinit /usr/bin/enlightenment -- -br +bs -dpi 96

随系统启动

外部链接