xprofile

来自 Arch Linux 中文维基

xprofile 文件,~/.xprofile 以及 /etc/xprofile, 允许您在刚打开 X 会话时运行命令 - 在窗口管理器运行之前。Xprofile 用于随会话自动运行程序,或从显示管理器启动,尤其是那个会话没有自带自动启动程序功能时 - 比如一个独立的窗口管理器

xprofile 文件在语法和概念上类似 xinitrc, ~/.xinitrc/etc/X11/xinit/xinitrc.d/.

兼容性[编辑 | 编辑源代码]

xprofile 和 xinitrc 文件在原生情况下会被以下显示管理器引用:

  • GDM - /etc/gdm/Xsession
  • LightDM - /etc/lightdm/Xsession
  • LXDM - /etc/lxdm/Xsession
  • SDDM - /usr/share/sddm/scripts/Xsession

在用 init 开启会话之时引用 xprofile[编辑 | 编辑源代码]

使用以下程序启动会话时能够引用 xprofile 文件:

以上程序,都会直接或间接地执行,~/.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 &