Wednesday, June 20, 2007

Fedora 7, Compiz, Nvidia

I play games on linux (q3, q4, doom3 etc.) with the nvidia drivers fine tuned with 'nvidia-settings' for anti-aliasing, v-sync, texture sharpening, digital vibrancy etc.. As I installed Fedora 7 some days back, I started using the wonderful desktop effects (compiz) as well.

Problem is that all this doesn't coincide with each other. Quake3 (or any other 3d-application) cannot run together with compiz desktop. Moreover Nvidia high quality settings may slow down compiz.

For this what I need is that compiz should stop when I run a 3d application. I also need nvidia high quality settings loaded only/exclusively for the application and not for the desktop.

Settings this up is very simple. Write a script "stopcompizfor.sh" which stops compiz, runs the application, and when it finishes, starts compiz again. (Note below is only for gnome)

#!/bin/sh
app=$@
if test -z "$app"
then
  echo "usage: stopcompizfor <3d-application>"
  exit
else
  compizpid=`ps -C compiz -o pid=`
  if test -z "$compizpid"
  then
    echo "Compiz not running anyway, continuing normally."
    $app
  else
    echo "Disabling Desktop Effects for [ $app ]"
    killall -9 compiz
    killall -9 gtk-window-decorator
    metacity --replace &
    $app
    echo "Starting Desktop Effects"
    killall -9 metacity
    gtk-window-decorator --replace &
    compiz --replace gconf &
  fi
fi


Kaur posted some changes to the dark blue part for KDE and Beryl, thanks :)

killall -9 beryl
killall -9 emerald
kwin --replace &
$app
echo "Starting Desktop Effects"
killall -9 kwin
beryl --replace &
emerald --replace &


Start 'nvidia-settings' and fine tune the settings upto your choice, this will create a file ~/.nvidia-settings-rc, save it in some other location. Run 'nvidia-settings' again and restore normal settings. Now, write a script "nvhqfor.sh" (nvidia high quality for) which loads the high quality settings, runs the application, and when it finishes, loads the default settings again.

#!/bin/sh
app=$@
if test -z "$app"
then
  echo "usage: nvhqfor <3d-application>"
  exit
else
  echo "Loading NVIDIA High Quality Settings"
  nvidia-settings --load-config-only
    --config=/home/user/.nv-high-quality-settings

  $app
  echo "Restoring NVIDIA Default settings"
  nvidia-settings --load-config-only
    ##--config=/home/user/.nv-low-quality-settings

fi


Now its all set, to run quake3 with compiz automatically stopped all I have to do is,

stopcompizfor quake3

and it runs like charm, if I wish to run quake3 with high quality settings, then I run,

stopcompizfor nvhqfor quake3
or
nvhqfor stopcompizfor quake3


not only this, I am a graphics programmer, and compiz effects (live thumbnail and expose) are helpful while programming. So my scripts are helpful there as well,
stopcompizfor ./renderer configs/puget-sound.cfg

w00t!

4 comments:

maruti said...

Sweet

kulbir said...

pretty nicely written shell scripts :) and a very good howto ... keep up !!!

Kaur said...

Thanks a lot, it's a really useful script. : )

I'll post my changes too, in case someone finds them useful. It's for Beryl and KDE. I commented out the killall commands as I thought they're not that necessary. It works, but I might be wrong about something. :D

#!/bin/sh
app=$@
if test -z "$app"
then
echo "usage: stopberylfor <3d-application>"
exit
else
berylpid=`ps -C beryl -o pid=`
if test -z "$berylpid"
then
echo "Beryl not running anyway, continuing normally."
$app
else
echo "Disabling Desktop Effects for [ $app ]"
#killall -9 beryl
#killall -9 emerald
kwin --replace &
$app
echo "Starting Desktop Effects"
#killall -9 kwin
beryl --replace &
emerald --replace &
fi
fi

If you're an old Beryl user just like me, you can use 'beryl-start' instead of "beryl --replace & and emerald --replace &". : )

I don't know about Compiz Fusion though. It's too unstable for me, so I'm still using Beryl. But would it work with that original script?

Kaur said...

Um, I guess the killall commands are necessary, so you can uncomment them again if you are using this modified script. I hadn't tested it enough, sorry. : )

Post a Comment