Ubuntu – How to switch between Unity and Unity 2D without logging out

unityunity-2d

I really like both Unity and Unity 2D. They currently have different issues, meaning that one does not have the issue the other has. For instance, when I play Battle for Wesnoth, then it integrates nicely with the global menu on Unity 2D, but not so well on Unity. So I tend to switch to Unity 2D while playing it, since I can then use my other monitor without switching between windowed and fullscreen mode. There are other cases as well.

However, for me, that currently means logging out and back in. I know that this isn't necessary, so I was wondering exactly what to do to switch between them in-place, without logging out.

Best Answer

I use a script to switch between Metacity and Unity and another to reload unity when I need to.

A probable solution would involve:

#!/bin/sh

#stop Compiz and thus Unity.

killall compiz &

#make sure to kill any conflicting processes (just in case, but this is optional).

killall metacity &

#This does not always exit cleanly, so kill it with fire for surety that it is dead.
killall unity-panel-service &

#load Unity 2D.

metacity --replace&
unity-2d-shell &
unity-2d-panel &
disown

^-- to load Unity 2D, and:

#!/bin/sh
killall unity-2d-panel &
killall unity-2d-shell &
killall unity-2d-spread &
killall metacity &
unity &
disown

^-- to load Unity 3D

You could save them as scripts in your ~/bin folder, for example as unity2dloader and unity3dloader respectively, and then simply run them from the run dialogue (alt+f2).

You could also place them in your nautilus scripts folder, and run them from the Desktop by right clicking on the Desktop, choosing the scripts menu and then the appropriate script.