翻译状态:本文是 Xprofile 的翻译。上次翻译日期:2015-03-10。如果英文版本有所更改,则您可以帮助同步翻译。
xprofile 文件,~/.xprofile 以及 /etc/xprofile, 允许您在刚打开 X 会话时运行命令 - 在窗口管理器运行之前。Xprofile 用于随会话自动运行程序,或从显示管理器启动,尤其是那个会话没有自带自动启动程序功能时 - 比如一个独立的窗口管理器。
xprofile 文件在语法和概念上类似 xinitrc (简体中文), ~/.xinitrc 和 /etc/X11/xinit/xinitrc.d/.
兼容性
xprofile 和 xinitrc 文件在原生情况下会被以下显示管理器引用:
GDM - /etc/gdm/Xsession
KDM - /usr/share/config/kdm/Xsession
LightDM - /etc/lightdm/Xsession
LXDM - /etc/lxdm/Xsession
在用 init 开启会话之时引用 xprofile
使用以下程序启动会话时能够引用 xprofile 文件:
startx
xinit
任何其他 ~/.xsession 使用 ~/.xinitrc 的显示管理器
以上程序,都会直接或间接地执行,~/.xinitrc (如果不存在的话,通常是复制自 /etc/skel/.xinitrc) 或 /etc/X11/xinit/xinitrc. 这就是我们要从下列文件引用 xprofile 的原因.
~/.xinitrc 和 /etc/X11/xinit/xinitrc 和 /etc/skel/.xinitrc
#!/bin/sh
# Make sure this is before the 'exec' command or it won't be sourced.
[ -f /etc/xprofile ] && source /etc/xprofile
[ -f ~/.xprofile ] && source ~/.xprofile
...
xinitrc.d/* 文件已经引用自默认 xinitrc 文件。
配置
首先,如果文件不存在的话创建 ~/.xprofile. 然后只需加入你想要随会话一同启动的程序的命令。见以下:
~/.xprofile
tint2 &
nm-applet &