I'm running Lubuntu 14.10. It seems that LighDM invokes /etc/X11/Xsession only if directed to so by the user. In fact there is no shadow of it in lightdm-session wrapper.

  • startx command line (wrapper around xinit for reasonable defaults) uses ~/.xinitrc if exists, otherwise uses /etc/X11/xinit/xinitrc.
  • /etc/X11/xinit/xinitrc sources /etc/X11/Xsession, that redirects output to .xsession-errors.
  • /etc/X11/Xsession sources ~/.xsessionrc if exists, then executes ~/.xsession if executable, sources if not.

What happens when using lightdm? If it doesn't source /etc/X11/Xsession, how could it possibly redirect errors to error-file ~/.xsession-errors (I couldn't find any informations on other scripts in /etc/X11/Xsession.d/)?

The man page for Xsession documents ~/.xsessionrc and ~/.xsession. It says that ~/.xsessionrc is only for setting variables and the ~/.xsession is for executing commands, but ~/.xsession gets sourced only if I create a custom *.desktop file in /usr/share/xsessions/ for it. Should I create a custom /etc/X11/Xsession.d/ file (like 40x11-common_xsessionrc works for ~/.xsessionrc), or just use ~/.xsessionrc to add any scripts?

Also, I'd like to know how x-window-manager and x-session-manager work through alternatives. I noticed that they seem to work if no ~/.xinitrc and ~/.xsession exist, and apparently they work only when running startx.

Thanks in advance for any answers.


Solution 1:

This bug

Bug #1001035 “lightdm uses a hardcoded path to .xsession-errors,...” : Bugs : lightdm package : Ubuntu

states that LightDM has the path for $HOME/.xsession-errors hard-coded in its source. And that really should be configurable.

Sadly, “modern” display managers seem to often not care about /etc/X11 much anymore, and re-invent the wheel… badly.
Probably because it is rather hard to find out why things are the way they are. (I tried. I still don’t know why there are so many files/scripts and what all their purposes are.)

E.g. SDDM doesn’t use .xsession-errors at all, and logs to some other strange location, if at all.


Addendum

The second question should really be separate.
Due to me still not knowing all about it, I can’t help with that.
But I think I can say that you probably shouldn’t create another custom session file.
Maybe the LightDM documentation helps you there…

About the third question: The man page for xinit and its associated man pages (from the same software package) explain this. There’s a list of alternatives, some in $HOME, some in /etc, some even in /usr/share/… sub-directories. But I think if there is none, some default is assumed too.
Sorry, this should probably be separate too. I only post what I do know.