PDA

View Full Version : Compiz toggle start|stop script


coffen
January 6th, 2008, 09:52 AM
I need to write a script for my 8 year old daughter (a Happy new Ubuntu user :)) that toggles compiz on or off.

The laptop she is using has Intel X3100 and video playback will not work if compiz is running.

I need the script to do the same thing as if the user checks none or custom on the Visual effects tab (see attached picture).

I assume checking the none button is equivalent to metacity --replace and checking the custom button is equivalent to compiz --replace

Am I correct?

To be able to write a toggle script I need a way to figure out if compiz is running or not. The script should turn it on if it is off and vice versa.
How can I check if it is running or not?

coffen
January 6th, 2008, 04:15 PM
Finally figured out how to do this.
Here is my start|stop script.

#!/bin/bash

function compiz_start() {
if
zenity --question --title "Start Compiz" --text $"Compiz effects are not activated.\n\n<b>Press OK to activate Compiz.</b>";
then
compiz --replace &
exit 1
else exit 1;
fi
}


function compiz_stop() {
if
zenity --question --title "Stop Compiz" --text $"Compiz effects are activated.\n\n<b>Press OK to deactivate Compiz.</b>";
then
metacity --replace &
exit 1
else exit 1;
fi
}

#Test to se if compiz is running
TEST=`ps aux | grep /usr/bin/compiz | grep -v grep | wc -l`

if [ $TEST -eq 0 ]
then
#compiz is not running and we should start it
compiz_start
else
#compiz is running and we shoud stop it
compiz_stop
fi

google01103
January 7th, 2008, 12:27 AM
oe compiz-switch http://forum.compiz-fusion.org/showthread.php?t=6463