How to switch between unity-3d and unity-2d without logging off?

Asked by Mossroy on 2012-03-02

When using Unity-3d, Compiz has annoying side-effects on videos.
When watching a video with any player, it is a bit jerky : it looks like a frame is dropped once in a while.

If you switch to Unity-2d (that does not use Compiz), the video is correct.
There is the same problem and workaround for 3D graphics (games etc).

My computer has a Core i5-650 processor, with Intel HD graphics. It has far enough power to decode videos, even in full HD.
When watching videos, the CPU stays low (in 2d and 3d).
The behavior is the same with all the players I tested : totem, vlc, XBMC.

On the XBMC website, Compiz is said to be "not compatible with XBMC" : http://wiki.xbmc.org/?title=XBMC_for_Linux_specific_FAQ#Compiz_is_not_compatible_with_XBMC
I tested the suggested workaround (Unredirect Fullscreen Windows) but it did not solve the problem. I also tested many other options (sync to vblank etc) : none worked, so I reverted to default compiz settings.

I would need to keep unity-3d most of the time, and sometimes be able to display a fullscreen video on the secondary screen (HDMI output), while keeping my windows and session on the main screen.
On Ubuntu 10.04 (Lucid), I did it "easily" by switching to metacity, with a "metacity --replace &" command-line. A "compiz --replace &" switched back to Compiz.
It still works with Unity on Precise beta 1 (except I also have to run "gnome-panel &" to have the panels), but it has a few drawbacks :
- I loose the menus of every open window on the main screen (because of the global menu of unity)
- It's very disturbing because the look and feel of unity and metacity are quite different. For example, I still tend to move the mouse on the left to open an application or switch between them...

That's why I was thinking that switching temporarily to unity-2d could be a solution.
But I did not find how to do it without logging off.

Fore reference, here is the way I was doing it with metacity on Lucid : http://forum.xbmc.org/showthread.php?t=100806

Question information

Language:
English Edit question
Status:
Solved
For:
unity-2d Edit question
Assignee:
No assignee Edit question
Solved by:
Gerry Boland
Solved:
2012-03-15
Last query:
2012-03-15
Last reply:
2012-03-14
Best Gerry Boland (gerboland) said : #1

Hey,
running "metacity --replace" will stop Compiz and install the lighter window manager Metacity. Unity is a plugin (which is responsible for launcher, hud, dash, .etc) in Compiz, hence you loose all the useful bits that gives you.

Unity2D is not tied into the window manager, it is instead just a buch of applications. Once you're got metacity going, in a terminal run "unity-2d-panel" to get the panel back, and
 - if on Precise, run "unity-2d-shell"
 - otherwise run "unity-2d-launcher"
to get your launcher, dash and other bits.

Of course you could always choose to run Unity2D all the time ;)
Hope this helps
-Gerry

Mossroy (mossroy) said : #2

Thanks Gerry for your answer.

Your command lines work pretty well when you run them by hand. But I faced minor issues when trying to script them :
- in some cases, I noticed that the panel does not show up. I suppose it's because the panel can't start if metacity isn't fully started. I managed to workaround this issue by adding a delay between the 3 commands. There should be a better way to handle that (detecting when metacity is ready) but I did not have the time to find
- if you run these commands in a terminal, even in the background with "&", you must never close this terminal. Else it kills your unity-2d processes, and you have a kind of "naked" metacity, without panel and launcher.

Currently, I have something usable on Precise by running a bash script from the unity launcher (via a .desktop file with "Terminal=false" option). This script to switch to unity-2d looks like :
   metacity --replace &
   sleep 2
   killall -q compiz
   sleep 1
   unity-2d-panel &
   sleep 1
   unity-2d-shell &

And to switch back to unity 3d :
          killall -q unity-2d-shell
   killall -q unity-2d-panel
   compiz --replace &

I change the status to "Solved".

Anyway, my opinion is that this should exist in standard Ubuntu, without manual scripting.
It looks like many use-cases are affected by a performance-loss due to Compiz (running some games, watching videos etc) : de-activating Compiz temporarily should be easily available to end-users (or even done automatically)

Mossroy (mossroy) said : #3

Thanks Gerry Boland, that solved my question.

Mossroy, your issue is also documented in a bug report. Please do head over there and "me, too" the bug. Thanks!

https://bugs.launchpad.net/ubuntu/+source/compiz/+bug/996343