Suspending Compiz

There are times when you find a game that for some reason just doesn't work well with Compiz. It may flicker over other windows, become distorted, or it may crash. The real fix for these comes in new X.Org drivers in the works, but for now the best solution is to suspend Compiz while you run a game.

Let's think of a way to do this. First, we'll obviously want to start Metacity and replace Compiz. Then, we want the game to run. And when we're done, Compiz should start up again. The most logical script would be this:

metacity --replace
compiz --replace

If you try to run the script above, you'd notice that Metacity would start, but nothing else would happen. This is because the commands are run synchronously, that is, when one finishes the next starts. Metacity will never finish unless you stop it. So, let's make it run in the background:

metacity --replace &
compiz --replace

The ampersand makes Metacity run in the background, allowing other commands to run. We then can run the game. The game shouldn't be run in the background, however, because Compiz would immediately replace Metacity again.

At the end of the script, we start up Compiz again. This is where you don't want to run the script in a terminal for once, because as soon as you close the terminal Compiz will quit. So, let's make a menu item for it. I'm a big fan of StepMania, so I'm going to run the version I have installed in my home directory:

metacity --replace &
cd ~/bin/stepmania
compiz --replace

If you run a command that requires a path, make sure to put the full path name in or your script may not run. We then add a menu entry in the Games menu:


Now whenever I decide to play StepMania, all desktop effects will be shut off. When I am finished, they will be switched back on again. This can be applied to almost any situation where Compiz needs to be off in your own scripts.

Avatar for jacob Jacob Peddicord -

Jacob is a web developer, student, and programmer from Ohio. He is a staff member at the Ubuntu Forums and is most likely a fanboy of the distribution. He loves to write in code and words, play video games, and rant about topics most would have abandoned long ago. Jacob uses GNOME and is never seen running stable software, much to the demise of his laptop.

Home » Articles »

Discussion: Suspending Compiz

  1. Yoni (guest)

    # Posted on 08 March 2008 at 08:22 PM

    You should place an ampersand after the compiz command as well, so after compiz kicks-in the script can terminate.

    <em>[The script itself will still terminate, but because it was started as a part of a script, Compiz will still terminate when the parent terminal is closed. This is why I suggested a menu item. -Jacob]</em>

  2. # Posted on 08 March 2008 at 09:03 PM

    [...] FOSSWire har skrivit en bra guide till hur du tillfälligt kan avaktivera Compiz för att åtgärda eventuella problem: Suspending Compiz [...]

  3. Geoff (guest)

    # Posted on 09 March 2008 at 12:19 AM

    Or you could try Compiz-Switch:

    "Compiz-Switch provides this on a single click. * If Compiz is running, it will switch to the default window decorator of your desktop environment. * If Compiz is not running, it will be launched immediately.

    There is no need to compile anything and the only dependency is a GNOME, KDE or Xfce environment with a running version of Compiz."


  4. # Posted on 09 March 2008 at 12:00 PM

    <strong>Story added...</strong>

    This story has been submitted to! If you think this story should be read by the free software community, come vote it up and discuss it here:

  5. Vadim P. (guest)

    # Posted on 09 March 2008 at 02:46 PM

    I just use compiz-switch... much less pain. Click on it, click on the game, and off you go. No prior setup needed.

    Though I don't do that usually since compiz in nvidia works fine. I've only experienced those problems on ati drivers.

  6. ethana2 (guest)

    # Posted on 09 March 2008 at 10:20 PM

    Why do you want a wm in RAM at all while you're playing a game? Waste of CPU cycles, waste of space. Suspend it to swap.

    ..see what you think of that.

    <em>[Window managers are run in RAM regardless of what you are doing. It definitely isn't a waste of CPU cycles, in fact it may use even more to swap it out. -Jacob]</em>

  7. Chris Lees (guest)

    # Posted on 10 March 2008 at 03:21 AM

    I used to use this kind of method to turn off Gnome's ESD so I could run Audacity, which at the time used only /dev/dsp.

    I can't remember the exact command, but it's something like "esdctl --shutdown" and "esdctl --start". With ESD, it takes about 2 seconds to turn off after the command returns, so you need a sleep statement:


    esdctl --shutdown sleep 2 audacity esdctl --start

    <em>[I remember doing this as well. Thankfully, with PulseAudio, all you need to do now is "pasuspender audacity" for the same effect. -Jacob]</em>

  8. # Posted on 10 March 2008 at 04:25 AM

    [...] FOSSwire » Suspending Compiz An easy way to suspend Compiz for when you are going to open a program that doesn&#8217;t run well with Compiz enabled. (tags: compiz linux tips) [...]

  9. unknownman (guest)

    # Posted on 20 April 2008 at 07:24 AM

    $ echo "


    metacity --replace &amp; cd ~/bin/$1 ./$1 compiz --replace " &gt; $ ./ myGame

  10. Steve (guest)

    # Posted on 08 June 2008 at 06:24 PM

    What about simply ending the script with 'exit'. That allows commands started from a terminal to continue even when the terminal is closed (essentially it closes the terminal but does not close the programs)

  11. Anonymous (guest)

    # Posted on 16 May 2009 at 08:25 AM

    What you're looking for is the nohup command which detaches any command from its shell.

    For instance: nohup compiz --replace &> /dev/null

    (By default nohup will log stdout and stderr to nohup.txt, the last part gets rid of that.)

  12. Tim (guest)

    # Posted on 01 July 2009 at 07:25 AM

    Couldn't you make one script that runs the argument that you give it without the desktop effects rather than a special script for each program

Home » Articles » Suspending Compiz