Xsession
The shell script a display manager runs after a successful login, which in turn starts the user's graphical session.
Once XDM has accepted the password, it runs Xsession as the user. The script loads resources with xrdb, sets up the environment and looks for the user's own ~/.xsession; if there is one it runs, otherwise a default session starts. The file plays the same part .xinitrc plays for startx, with the catch that the session ends when the script does — and with it, you are logged out.
Distributions built on it. Debian's /etc/X11/Xsession runs a directory of small scripts in Xsession.d, where packages can hook in ssh-agent, D-Bus or input methods without touching anything else. The same script redirects all output to ~/.xsession-errors, the file where every program launched from the desktop writes its warnings. It is invaluable when debugging and has a well-earned reputation for occasionally growing until the home directory is full.