xprofile
Related articles
An xprofile file, ~/.xprofile and /etc/xprofile, allows you to execute commands at the beginning of the X user session - before the Window manager is started. Xprofile is of particular use for autostarting programs with a session, started from a Display manager, when that session does not have its own autostart facility - a standalone Window manager for example.
The xprofile file is similar in syntax and in concept to xinitrc, ~/.xinitrc and /etc/X11/xinit/xinitrc.d/.
Compatibility
The xprofile and xinitrc files are natively sourced by the following display managers:
- GDM -
/etc/gdm/Xsession - KDM -
/usr/share/config/kdm/Xsession - LightDM -
/etc/lightdm/Xsession - LXDM -
/etc/lxdm/Xsession
Sourcing xprofile from a session started with xinit
It is possible to source xprofile from a session started with one of the following programs:
-
startx -
xinit - XDM
- SLiM
- any other Display manager which uses
~/.xsessionor~/.xinitrc
All of these execute, directly or indirectly, ~/.xinitrc (usually copied from /etc/skel/.xinitrc), or /etc/X11/xinit/xinitrc if it does not exist. That is why we have to source xprofile from these files.
~/.xinitrc and /etc/X11/xinit/xinitrc and /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/* files are already sourced from the default xinitrc file.
Configuration
Firstly, create the file ~/.xprofile if it does not exist already. Then, simply add the commands for the programs you wish to start with the session. See below:
~/.xprofile
tint2 & nm-applet &