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.

202 total views, 4 views today

2
Leave a Reply

avatar
1 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
2 Comment authors
tinuzKevin Recent comment authors

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

  Subscribe  
newest oldest most voted
Notify of
Kevin
Guest
Kevin

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

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 …