Switch to a second graphical user session without closing the first one

I have two users, one for work and one for home in Lubuntu 19.10.
While on one of them, suddenly I need to switch to the other one without the need to close the first graphical session completely. Finish my stuff and then return to the first session.

How can I accomplish this?
I have digged Internet and found that using lightdm is able to do that with dm-tool switch-user-to another-login, but I’m not sure to change the display manager (there are too many dependencies to install it!).

So, is it possible to do what I require? In the old days I used to start a new VT (Ctrl+Alt+F3, for example), login and then startx -- :1 and voilá! But now I believe that’s not the way to go…

Maybe another display manager like gdm or lxdm?
Or is the only solution to use lightdm?

1 Like

I had success with two graphical logins but slightly different case.

I had a setup with Ubuntu and Ubuntu MATE together. Initially I used to logout and login to another DE but got tired and wanted to try this. IIRC, all I did was to start Ubuntu from GDM as normal, put entry for MATE in my .xinitrc, go to another virtual terminal and just did startx. I don’t remember adding anything about displays like :0 or :1…I was able to use two different desktops. Also, in my case was using same account.

Well, I am on Lubuntu 20.04. To test your scenario, I created a test account. First, I put exec lxqt-session in the ~/.xinitrc file of second user. With this, startx gives me a bare bones openbox session. Then I checked /usr/share/xsessions/Lubuntu.desktop and found following entry. Putting it in ~/.xinitrc of second user enabled me to login to default Lubuntu desktop.

Exec=env LXQT_DEFAULT_OPENBOX_CONFIG="/etc/xdg/xdg-Lubuntu/openbox/lxqt-rc.xml" /usr/bin/startlxqt

Now I can login from SDDM for first user, go to another VT and do startx to start graphical session for second user, then do Ctrl+Alt+Fx / Ctrl+Alt+Fy and switch between two graphical sessions for two user accounts.

Hi, @saivinob !

First of all please forgive me for taking so much time to respond. I was really very busy at work. I’m sorry.

Your response is so kind! I am just testing it. I had lost all hope to understand how to accomplish this scenario. Thank you so much for taking the time to help me. Need to say that your reasoning also helped to understand a little how this X session stuff works. It is still a foggy land to me.

As you stated, I can start a second graphical session with a second user. In fact it is not so bad to start a new openbox session, though Lubuntu is easier to have it all set up. However, I cannot keep the first session alive after I go switch to the second one. It dies after I try to switch back to it.

My ~/.xinitrc file only contains what you suggests:
Exec=env LXQT_DEFAULT_OPENBOX_CONFIG="/etc/xdg/xdg-Lubuntu/openbox/lxqt-rc.xml" /usr/bin/startlxqt

I am missing something else… Do not know why session 1 dies and opens ssdm.

Hi @lobaluna,
You are welcome. We are all learning. I’m no expert myself.

In my case the X did not die by switching between VTs. Have you put that Exec... line in .xinitrc of both users? I put it only in second user’s xinitrc. For first user, I login with SDDM as normal and for second user use startx.

I must admit I’m on virtual machine, if that matters.

Hi, @saivinob

Yes, we both are learning! My findings are as follows.

I had put the Exec... line just in the second user. Now it is already in both users (with the appropriate path to the local openbox configuration: /home/user1/.config/openbox/lxqt-rc.xml)

After that change, I tried to switch forth and back to user2, but X still crashes. The message in .xsession-errors is:

X connection to :0 broken (explicit kill or server shutdown).
Gdk-Message: 23:12:19.295: dropbox: Fatal IO error 11 (Resource temporarily unavailable) on X server :0.

XIO:  fatal IO error 2 (No such file or directory) on X server ":0"
      after 857 requests (857 known processed) with 0 events remaining.

Then I figured out that maybe if I start each session from command line using startx could work, and it worked!

Here I ask for your opinion: maybe some lines in Lubuntu session or the part of SDDM connected to a Lubuntu session is not working, something apart from startlxqt script… When switching back and forth taking SDDM as entry point, it fails. However starting with startx from any VT (and .xinitrc as you suggested), it doesn’t fail!!!

I’m afraid I do not know much to answer your question. You may look at error that mentions ‘dropbox’, if you have it installed. There may be other clues if you check the full log.

Oh, no worries about the crash, @saivinob. I just put it there to show you there is a crash with X. There no more in the full log after that.

Apart, when I do start the X from VT (without SDDM) to start the Lubuntu session, I can switch forth and back to a second graphical session. When the opposite, when I start an X session from SDDM, and then try to switch to a second graphical session, the first X crashes.

Anyway, your suggestions are so much help. Thank you!

Just FYI I’ve been watching this. I know that Kubuntu can switch to different graphical user sessions. I discussed it briefly with LXQt and it seems like the sort of thing that would ultimately become problematic at some point given the limited number of VTs. I’m not sure how KDE gets around this but the lack of enthusiasm for it makes it clear we’re not likely to see this become a real feature in Lubuntu.

Hi, @wxl

So if KDE can accomplish it, it is not a SDDM’s lack of ability…
Funny thing. My X do not crashes if I lock session 1 before I switch to session 2.

I have this workaround, hope it helps someone else.

Right. It doesn’t have to do with SDDM, but KDE’s session manager.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.