Menu Close

Automatically disable Compiz when launching games

When launching OpenGL applications games, google-earth etc you sometimes need to disable compiz. Most of you probably use fusion-icon or similar applications instead of enabling/disabling compiz via terminal.

Lets introduce you a very simple script I found (via google of course) to automatically disable compiz when launching your applications/games. It will also restore the compiz after exiting the application.


Create an empty file called “game” under /usr/bin/
To make the file copy+paste the following line in your terminal window:

sudo gedit /usr/bin/game


Copy and paste the following text into the file:

#!/bin/bash
#
COMP="false";
if ps -A | grep compiz > /dev/null ; then
echo "Warning: Compiz Detected!!!"
metacity --replace > /dev/null &
COMP="true"
fi
echo "Starting"
$1
echo "Finish"
if $COMP ; then
echo "Warning: Starting Compiz!!!"
compiz --replace > /dev/null &
fi
exit

Then save and close the file.

To touch and make the file executable copy+paste the following line:

sudo touch /usr/bin/game && sudo chmod +x /usr/bin/game


Now you can just type game before before your application/game command.Example :

$game eternallands
$game wesnoth

Most credits go to Amof from ubuntuforums.
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Kevin
Kevin
13 years ago

on the first step when I try to create the ‘game’ folder in the bin directory. I get a permission error that doesn’t allow me to create it.

tinuz
Admin
13 years ago
Reply to  Kevin

You need to make a new text file … i added a line that will make the file the easy way. Copy+paste the following line in your terminal window:
sudo gedit /usr/bin/game
When done save and close the file …