I've been developing a workaround for
https://bugs.launchpad.net/ubuntu/+source/linux-restricted-modules-2.6.24/+bug/197209
(fglrx + compiz fusion won't resume) and I think I have nearly
everything working really well, but there's still a niggling problem.

I must stop all compiz processes before suspend invokes chvt or resume
fails.  I'm killing and re-launching the process that started
compiz.real (in my case, fusion-icon) after resume.  When I do that
manually (or simply choose "reload window manager" from the fusion-icon
menu), everything works fine.  When I try to do the kill/re-launch as
part of my resume script, compiz runs, but with different settings than
the usual that come from fusion-icon.  Instead it seems to be using
the settings that you get when enabling "Desktop Effects" in Ubuntu.
For example, instead of a rotating cube, I get the toned-down ubuntu
desktop sliding effect, and instead of my usual 4 desktop workspaces I
get 2.

This problem occurs even when 

  Preferences > Appearance > Visual Effects

has desktop effects disabled.  Can anyone suggest a way to make this
work as I intend?  My scripts are enclosed.

Thanks in advance,
Dave

=== /etc/pm/config.d/00-compiz-stop.sh ===
# For each running instance of compiz.real, record the parent process
# so that we can restart it after resume.  We're going to kill
# compiz.real, but the parent processes seem to keep running anyway.
# Upon resume we'll simply kill the parents and re-issue the commands
# that were used to start them.
export COMPIZ_PARENTS
for x in `pgrep compiz.real`; do
    # This is usually "fusion-icon..." or "compiz-tray-icon..." or
    # "compiz --replace", etc.  
    COMPIZ_PARENTS="$(echo $(ps --no-headers -o ppid $x)) $COMPIZ_PARENTS"
done
        
# Define an override to chvt that sneaks in and kills off all compiz
# processes before fglrx can break trying to suspend them
chvt() {
    # Now kill off all the compiz.real processes and wait for them to
    # exit before we do the VT switch
    killall -s 15 compiz.real
    while pgrep compiz.real; do sleep 0.1; done
    # Remove this definition so we don't recurse forever.
    unset -f chvt
    # Now do what we were asked to do.
    chvt "$1"
}
=== /etc/pm/sleep.d/00compiz ===
#!/bin/bash

. /usr/lib/pm-utils/functions
. /usr/share/acpi-support/power-funcs

resume_compiz()
{
    # Iterate over the pids of all the processes that launched compiz
    local compiz_parents="$(restorestate compiz_parents)"
    local compiz_parent
    for compiz_parent in ${compiz_parents}; do
        # Remember the command used to invoke it
        local compiz_cmd=$(ps --no-headers -o cmd ${compiz_parent})

        # Look in the process environment for the DISPLAY setting
        local displaynum=$(grep -zx "DISPLAY=:.*" /proc/${compiz_parent}/environ | sed -r -e 's/DISPLAY=:([0-9.]+)/\1/')

        # If we have found a display, we can kill the compiz parent
        # process and re-invoke it.  If we've failed to find the
        # display, X will resume without a WM and it will be up to the
        # user to re-invoke the compiz parent manually.
        if [ -n "$displaynum" ]; then

            # set up XAUTHORITY for that display
            getXuser
            local compiz_user="${user}"
            
            # what /usr/share/acpi-support/power-funcs does is
            # actually inadequate in the case where the user has lost
            # write permission on his own .Xauthority file, so we make
            # a list including any likely fallback files, and keep
            # trying until we find one that works.
            local xauth
            for xauth in "$XAUTHORITY" /tmp/.gdm* "" ; do

                if [ -f "$xauth" ] && ( \
                    sudo -u "$compiz_user" touch "$xauth"); then

                    # Now we can kill the invoker of compiz.real...
                    kill -s 15 $compiz_parent
                        
                    # ...and reinvoke it
                    sudo -b -H -u "$compiz_user" XAUTHORITY="$xauth" DISPLAY=":$displaynum" ${compiz_cmd}
                    break
                fi
            done
        fi
                        
        # Move on to next compiz invoking PID
    done
}

case "$1" in
	suspend|hibernate)
        savestate compiz_parents "$COMPIZ_PARENTS"
		;;
	resume|thaw)
		resume_compiz
		;;
	*)
		;;
esac

exit $?
-- 
Dave Abrahams
Boost Consulting
http://boost-consulting.com
_______________________________________________
Dev mailing list
[email protected]
http://lists.compiz-fusion.org/mailman/listinfo/dev

Reply via email to