Switch between desktop environments instantly within the running desktop session

Solution 1:

I got a nice trick while I was looking for WM key-binding, reading man pages.

man dm-tool

dm-tool is a tool to communicate with the LightDM display manager.

   list-seats
          List the active seats and sessions that are running.

   add-nested-seat
          Start an X server inside a session and connect it to a display manager.

   add-local-x-seat DISPLAY_NUMBER
          Connect an existing X server to the display manager.

   add-seat TYPE [NAME=VALUE...]
          Add a dynamic seat.
  • Run:

    $ dm-tool add-nested-seat
    /org/freedesktop/DisplayManager/Seat2
    

    Update: With newer release, it is possible to control the dimensions of the new window or let it be fullscreen by adding parameters --fullscreen or --screen XxY, see dm-tool --help.

  • Got new window with new session (titled Xephyr on):

    enter image description here

  • Then login using other desktop (LXDE):

    enter image description here

  • You can toggle if mouse and keyboard should be captured in the new session by typing Ctrl-Shift.

  • Check seat list:

    $ dm-tool list-seats
    Seat2
      CanSwitch=false
      HasGuestAccount=true
      Session2
        UserName='sneetsher'
    Seat0
      CanSwitch=true
      HasGuestAccount=true
      Session0
        UserName='sneetsher'
    

  • To run in full screen:

    Xephyr :1 -br -fullscreen &
    dm-tool add-local-x-seat 1
    

Reference: Using_Xephyr

Solution 2:

This is a hypothetical answer, but perhaps someone with more knowledge on the subject can build upon my statements. If they are run under a differen't xserver output then you could switch between them by simply pressing Ctrl+Alt+F1, Ctrl+Alt+F2,...etc. Where F1 is X1, F2 is X2,..etc. I'm guessing the commands would be along the lines of:

  1. In terminal type: sudo xhost +

    Please note this presents a security risk because you've just allowed any of your x outputs to access.

  2. Ctrl+Alt+F1

    This takes you to X output 1, the default desktop is on f7

  3. Type: export DISPLAY=localhost:1

    1 because you are on x output 1, the default is on 0, and for additional outputs you will use higher numbers eg: 2,3,4 etc.

  4. Type: startxfce4 (XFCE), startkde (KDE) or startlxde (LXDE) to get the desktop to open in the new X output.

This doesn't work for me yet, I believe it's because you must be running it as a different user, because when I try it says the desktop is already running on the other localhost? This is as far as I've been able to get with this.

Solution 3:

Alternative point of view

It is possible to run another xsession, for another user.

Just create new user

sudo useradd test_test

Now you only need to lock your account Ctrl+Alt+L, then switch to a new added user and login. In login menu you can choose between installed Desktop Environment.

It will automatically starts new xsession in new tty. For me it is tty8. Now using Ctrl+Alt+F7, I can return to my user xsession. Using Ctrl+Alt+F8 back to new user xsession.