If I unterstand it correctly, LightDM has replaced GDM per default. I wonder if it's possible to make it run the things I put in my .xinitrc file ... what I need is an option below "Unity" and "Unity 2D" which says "Run a user-defined session".

Is that possible? Should be the easiest thing, but I did not get a clue so far. I export and define and run a lot of things in this file, so it's pretty important for me to have control over that.

What I do NOT want is a custom session in /usr/some/where, I only want it to run the stuff from each user's xinitrc (or similar).


Create a new file /usr/share/xsessions/custom.desktop with:

[Desktop Entry]

You should now have a new session option during login, Xsession will load the user's ~/.xinitrc.

  • 2
    Ubuntu only considers ~/.xsession or maybe ~/.xsessionrc and ~/.Xsession now (12.04)
    – guigouz
    Sep 20 '12 at 23:14
  • Does one need to restart X, or simply logout, for this to take effect?
    – tshepang
    Nov 23 '13 at 15:46

Create a new file /usr/share/xsessions/default.desktop (The name is up to you, but it has to have .desktop suffix):

[Desktop Entry]
Comment=This runs user session and logs you into Ubuntu

Now when you select this session in lightdm and log in, your ~/.xsession file, if exists, will be executed.

Note that the user's file that is executed is ~/.xsession, and not ~/.xinitrc, which was mentioned in the question. (~/.xinitrc is used when the X session is started using the startx script from a command line.)

Some explanations: The Name entry is what lightdm would display for this session. The Exec entry is the important thing, and it should be the name of the program that starts the actual session. When you log in, lightdm calls the /etc/X11/Xsession script, passing it the value of Exec as an argument, and Xsession will, eventually, execute this program (for example, it could be startxfce4 for starting a xfce4 session). If the Exec entry is the special string default, then Xsession will execute the user's ~/.xsession file. (Xsession would also execute ~/.xsession if it's called without aruments.)

Sorry, I'm new here and hence cannot comment on other people's answers, but I'd like to comment on the accepted answer, to make things clearer. As per my explanation above, what will happen with that answer's method is that Xsession would be called by lightdm with an argument which is (the full path of) Xsession. So Xession will run and then call itself, this time with no arguments. The second Xsession, being called with no arguments, will execute the user's ~/.xsession. So the desired action will, eventually, be taken, but in a bit awkward way.

  • Typo: /user -> /usr (cannot edit as edits must be at least six chars long, LOL).
    – spawn
    Dec 4 '20 at 7:51

To use olvwm:

1) Type sudo apt-get install olvwm in a console

2) Create this session :

[Desktop Entry]
Name=Open Look

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.