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.)

  • 2
    Let's see who steps up with an authoritative answer but my feeling is that, as far as Ubuntu and the official flavors go, you need to log out and log back in. There was/is something called Hybryde Fusion 13.04 which seems to offer something related but that would be off-topic here. – user25656 Feb 5 '14 at 17:26
  • yeah that seems to offer some HY-D-V1 Desktop environment.. the appearance seems to be quite close to GNOME3, but I hope it offers better experience.. – precise Feb 5 '14 at 17:50
  • And then I think Zorin also offers something similar. That too would be OT :D I've decided a pure Openbox session with no desktop is good enough for me ;) – user25656 Feb 5 '14 at 18:05

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 the active seats and sessions that are running.

          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

    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

  • To run in full screen:

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

Reference: Using_Xephyr

  • it's not exactly what I'm looking for, but Xephyr is a good tool to know about.. more than +1.. only dm-tool add-nested-seat seems to be working for me, can't start with a specified resolution or fullscreen with Xephyr.. and shut down doesn't close the slave X; I have to click close button (is that good?).. – precise Feb 11 '14 at 15:58
  • dm-tool add-nested-seat works with some defaults thats why I run Xephyr as full screen in new display then run dm-tool to that display. "Shut down doesn't close the slave X" because it's not system visualization, but not sure if there better way. That session can even be closed as any window with Alt+F4. And you can switch between as any window Alt+Tab. – user.dz Feb 11 '14 at 16:06
  • 2
    In the meantime dm-tool was updated, it now accepts options --fullscreen or --screen 800x600 so it is probably not always necessary to run Xephyr directly to achieve this. Type dm-tool --help to see it documented. (The man page will probably be updated later with the newer options.) – mit Aug 6 '17 at 10:32

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.

  • 1
    I gave it a try, I have only Gnome/Unity. startx didn't work. So I run it in background startx &, it works and created new gnome (my default) session with same user on tty8 (Ctrl+Alt+F8). I tried again with sudo xhost - as I though it's the same user why not, It works too. Logout brings me back to tty1. – user.dz Feb 7 '14 at 15:36

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.

  • 1
    that's simply switching between user accounts.. I'm looking for a way to change to a different environment in the same session where my applications should preserve their state between the switch... – precise Feb 11 '14 at 16:37
  • 1
    This is exactly what I was looking for to boost productivity by focusing on one compartment at a time. – Banago Sep 5 at 8:52

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.