Ubuntu – Switch between desktop environments instantly within the running desktop session

desktop-environments

Is there a way to instantly switch (preferably from the command line) between one desktop environment and another; say, from Unity to classical GNOME without having to close any of the running applications in the same desktop session?

(Please note that it's not about installing the environments.)

Best Answer

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