#!/bin/bash
#-----------------------------------------------------------------------------
# x11spice_connected_gnome
#  A sample script to use with the x11spice 'on_connect' function.
# This script is called when a connection occurs.
# This sample script saves the current desktop background, and turns it red.
#-----------------------------------------------------------------------------
G=`which gconftool-2`
BG_DIR=/desktop/gnome/background
SAVE_KEY=$BG_DIR/x11spice_save_background

if [ -z "$G" ] ; then
    echo Error: gconftool-2 not available 1>&2
    exit -1
fi

# Save the backup XML to a temporary file
dump_file=`mktemp`
$G --get $SAVE_KEY >$dump_file 2>/dev/null
c=`wc -c $dump_file | cut -f 1 -d ' '`
if [ $c -eq 0 ] ; then
    echo Error: Could not load $SAVE_KEY 1>&2
    rm -f $dump_file
    exit -2
fi

# Restore the backup XML and then clear the backup key
$G --load="$dump_file"
$G --unset $SAVE_KEY

rm -f $dump_file

exit 0
