Compiz NVIDIA and ATI games auto switch off/on scripts

Nvidia LogoLast week I've stumbled upon this article with the title "The Cost Of Running Compiz" that bashes Compiz Fusion for killing Linux gamers (is this oxymoron or what?) frame rates. Doctor is in the house. Read on...

It would be ideal that you can have Compiz with ton of eye candy and glitch free 3D games. We know that doesn't work. But instead wouldn't it be possible to have our eye candy Compiz disabled while gaming and re enabled when returned to desktop? Sure. Peace of cake. Here's the idea and the steps to do so...

My idea is to make simple BASH script that could be used to launch our favorite games. Then we could replace launcher of any game that has Compiz illness (urban terror anyone?) with our script. We will pass name of the game as a parameter to our script. Additionally i love my 3D games with Anti-alliasing and Anisotropic filtering and my Compiz without it. We can do that too if we have Nvidia card at hand.

Step 1. (only NVIDIA owners)

If you have ATI card, skip this step. If you have NVIDIA card and want to automatically load Nvidia profile when you start your game, and unload it after you exit game, you do this... Run Nvidia Settings tool to make our settings profile for 3D games (AAA and AF). Press Alt+F2 and type

nvidia-settings

and press Enter. You can also navigate through menus to find Nvidia X Server Settings item. Now you set up your 3D games profile (AAA and AF as you wish) and click nvidia-settings Configuration from the left pane of the window. Click Save Current Configuration and then save it under .games-settings-rc file name in your home directory. After saving your 3D games profile in your home directory you return your Nvidia settings to the default (no AAA and AF) or whatever you want to be your default every day settings and click Quit.

Step 2. (Both NVIDIA and ATI cards)

Now you must download my scripts by clicking on the link at the end of this article. In zip file there are two scripts:

  • game-starter-nvidia-v0.2.sh - this one uses created Nvidia 3D profile to tweak AAA and AF when you start your favorite game and also disables Compiz while gaming. After you quit game your settings are rolled back to no AAA/AF with compiz turned on or whatever is your default in your nvidia-settings. This one works with NVIDIA cards only (at least for now)!
  • game-starter-all-v0.2.sh - this one just disables Compiz when in the game, and enables it when you are back on desktop. Works with both NVIDIA and ATI cards!

Choice between two versions of the script is yours depending whether you want to manage your AAA and AF setting manually and whether you have NVIDIA or ATI card in your box.

First download the scripts and put them to your home directory. We will now unpack them to ~/bin directory because bin directory in users home is by default in ones environment PATH. This way you can run your scripts without typing full path.

To install scripts you can use following code:

mkdir ~/bin && tar -xjvf 'game-starter-v0.2.tar.bz2' -C ~/bin/
chmod +x ~/bin/game-starter-all-v0.2.sh ~/bin/game-starter-nvidia-v0.2.sh

    Step 3. (both NVIDIA and ATI cards)

    Now start you game without worrying about Compiz killing your fun. Use this commands:

    game-starter-all-v0.2.sh GAMENAME

    or if you have selected game-starter-nvidia-v0.2.sh

    game-starter-nvidia-v0.2.sh GAMENAME

    Example: For starting Urban Terror with disabled Compiz and with use of .games-settings-rc Nvidia profile for AA and AF settings I would type this:

    game-starter-nvidia-v0.2.sh urbanterror

    Now the best part, you can modify your menu game launchers for games with this little script. You can use different script whether particular game has AAA and AF settings in its options menu or not. Once you set it up, you forget about it.

    Please comment if script works or especially if it doesn't by clicking on the link at the top of this article (registration not necessary to comment - for now).

    Have fun!

    Changelog

    • Initial release.
    • Now this scripts can detect if compiz isn't running and in that case do nothing to suspend it when you enter the game. Besides that v0.2 scripts will use Ubuntu Notify OSD to inform you when Compiz is being suspended and restarted.

    HERE's the v0.2 of the script (Ubuntu Maverick and older because Compiz detection isn't working on Natty, by the way thanks Canonical for messing up our Ubuntu)

    HERE's the v0.1 of the script (all Ubuntu versions, doesn't detect is Compiz running or not but works great)

    Enjoy!

DevGenii

A quality focused Magento specialized web development agency. Get in touch!

8 thoughts on “Compiz NVIDIA and ATI games auto switch off/on scripts

  1. rewind

    Been using your script in Maverick for a while and I found it very useful, however after upgrading on natty the script doesn’t work anymore. Do you have any idea why and how can I make it work again? Thanks!

    Reply
  2. rewind

    Well first libnotify-bin was not installed, but I think that not this was the problem. I’m using Gnome-classic desktop instead of Unity and the first part of the script that checks if compiz is running returns “0”. Thanks for the idea.

    Reply
  3. Marko Martinović Author

    @rewind

    That is the problem, to test is compiz running. Canonical has modified Compiz for Unity stuff. Thanks for reporting problems, I will install Natty as virtual machine (i really don’t like Natty or Unity) and try to find another way to detect is compiz running. Until then you can use v0.1 of the script that is dumb in a way that it doesn’t check is Compiz running or not so it should work 🙂 Natty is in many ways broken release for me and many other people I know 🙁

    Reply
  4. rewind

    For me also, I had to fix so many broken things, such as emerald or gnome-panel /skype doesn’t show up there/. Maybe the only thing I find really useful is the new compiz function to automatically resize windows, but with the classic gnome. I find Gnome 3 way more useful and beautiful than Unity, but only in Desktop. Of course Unity has it’s advantages when you use it on 10″ 1024×600 screen.

    Reply
  5. Marko Martinović Author

    @rewind

    Hi rewind. I don’t like Gnome 3 but i like it more than Unity. Gnome 3 is around for so long so we can let it “find its way” and to experiment, but Unity is so new and so what I don’t want on my desktop. I’m running Lucid and Maverick on my desktops until infamous kernel 2.6.38 power drain bug is resolved, then I’m installing Mint if something better doesn’t come along (Gnome 2 fork anyone ??) 🙂

    You can find my view on new Linux desktop situation inside this article I wrote after trying Unity and Gnome 3:

    http://www.techytalk.info/ubuntu-11-04-natty-narwhal-review/

    Reply
  6. rewind

    @Marko Martinović
    Thanks for the idea, I think the same about natty. I had to fix many broken things like emerald or gnome-panel not showing skype etc. I’ll use 0.1 version for now 🙂 Thanks again!

    Reply
  7. Marko Author

    I’m not usually unfriendly towards new stuff, but Natty is step down it in many aspects. But nice thing is that Maverick and Lucid are solid releases 😉

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *