SUSE Conversations


How to Make GNOME Desktop Effects Disabled by Default



By: mikewillis

June 11, 2009 2:14 pm

Reads:953

Comments:0

Rating:0

Two things made me think that Desktop Effects should be disabled by default. Firstly, I have discovered that Desktop Effects get disabled when Mathematica 6 or 7 is run. if Mathematica causes problems, so potentially may other applications. Secondly, on a couple of occasions I’ve seen Desktop Effects get disabled during a session for no apparent reason. It’s only happened twice, but that’s twice more than it should have happened. The default settings given to users should be totally solid. They should not be known to break when a certain application is run, or be to any degree prone to unexplained breakage. I like Desktop effects and as such do not want to completely disable them by removing all the relevant packages. What I want to is for them to be off by default and allow users to enable them should they wish to do so. Unfortunately GNOME provides no configuration option to achieve this.

Desktop Effects are provided by the Compiz window manager. SLED 11 (and other popular current distros) includes two window managers for GNOME – Metacity and Compiz. When you enable or disable Desktop Effects you are actually changing which window manager GNOME is using. Enable Desktop Effects and Compiz is invoked to replace Metacity. Disable Desktop Effects and Metacity is invoked to replace Compiz. (As a quick aside, Metacity is capable of some compositing effects which can be enabled by setting the GConf key /apps/metacity/general/compositing_manager to true.)

When a user logs in the script /usr/bin/gnome-wm is run. It is this script which decides whether to invoke Compiz or Metacity. Two factors determine which window manager is run. If there is a file in the user’s home directory called ~/.config/compiz/enablecompiz, then Compiz is used. If there is a file in the user’s home directory called ~/.config/compiz/disablecompiz, then Metacity is used. (Both of the aforementioned files are empty) If neither of these files are present, then a test is performed to determine whether the machine’s hardware is capable of running Compiz. If the hardware passes the test, Compiz is used. If it fails, Metacity is used.

So the solution to making Desktop Effects be off by default, is to make GNOME use Metacity as the default window manager, not Compiz. The way I did that was to replace /usr/bin/gnome-wm with my own modified version.

Take a copy of gnome-wm and call it /usr/bin/my-wm. Open my-wm in your text editor of choice and replace all instances of the string gnome-wm with my-wm. Now look through the file and find these two lines:

if [ -f "$COMPIZ_ENABLED_FILE" ] ; then
   KNOWN_WM="compiz-manager $KNOWN_WM"
else
   if [ ! -f "$HOME/.config/compiz/disable-compiz" ] ; then
      # Check to see if hardware is supported by compiz, to have it as default WM if so
      CM_DRY=yes compiz-manager > /dev/null 2>&1
      if test $? -eq 0; then
         KNOWN_WM="compiz-manager $KNOWN_WM"
      fi
   fi
fi

These are the lines that determine whether to use Compiz or not. To achieve the desired behaviour, comment out the lines which perform the hardware check, like so:

if [ -f "$COMPIZ_ENABLED_FILE" ] ; then
   KNOWN_WM="compiz-manager $KNOWN_WM"
#else
#   if [ ! -f "$HOME/.config/compiz/disable-compiz" ] ; then
#      # Check to see if hardware is supported by compiz, to have it as default WM if so
#      CM_DRY=yes compiz-manager > /dev/null 2>&1
#      if test $? -eq 0; then
#         KNOWN_WM="compiz-manager $KNOWN_WM"
#      fi
#   fi
fi

Now create a .desktop file for the script. Copy /usr/share/applications/gnome-wm.desktop to /usr/share/applications/my-wm.desktop and modify the Exec line to say my-wm.

Finally we need to tell GNOME to use my-wm instead of gnome-wm by changing the GConf key
/desktop/gnome/session/required_components/windowmanager You can change this using the defaults window in gconf-editor or on the command line using:

$ gconftool-2 --direct \
   --config-source xml:readwrite:/etc/gconf/gconf.xml.defaults \
   --type string \
   --set /desktop/gnome/session/required_components/windowmanager "my-wm";

Obviously you need to change that setting as root. If you use gconf-editor make sure you are changing the Defaults rather than just the root user’s settings. by selecting File -> New Defaults Window.

For a final touch I’ve set up a warning message that gets displayed when a user runs the Desktop Effects module in the Control Panel. This involves modifying the file /usr/share/applications/simple-ccsm.desktop Since this file could be overwritten by an update, the modification is applied by a script which runs at boot along with various other maintenance scripts I have in place. The script looks like:

#!/bin/bash
# causes a warning message to be displayed when user launches the Desktop Effects
# module in the Control Panel
desktopfile=/usr/share/applications/simple-ccsm.desktop
warningblurb="'Please note that running some applications can cause Desktop Effects to be disabled. Mathematica 6 and 7 are two known examples.\\\nFurther information can be found in the FAQ at [put an url to your FAQ here]'"
# wrapping both commands in a bash shell is a bit weird but the only way
# I could make it work. Every other method I tried resulted in the warning
# being displayed but simple-ccsm not being launched.
newcmd="Exec=bash -c \"zenity --warning --text $warningblurb; simple-ccsm\""
sed -i "s!^Exec=.*!$newcmd!" $desktopfile;
VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)

Tags: ,
Categories: SUSE Linux Enterprise Desktop, Technical Solutions

Disclaimer: As with everything else at SUSE Conversations, this content is definitely not supported by SUSE (so don't even think of calling Support if you try something and it blows up).  It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test, test, test before you do anything drastic with it.

Comment

RSS