#!/bin/bash
K='/desktop/gnome/background/picture_filename'
K2='/desktop/gnome/background/primary_color'
V=`gconftool -g "$K"`
xdark -i
B=(`xdark`)
inverse=`python -c "print ${B[0]} > ${B[1]}"`
if [ -n "$V" ]; then
	V1="${V%.jpg}"
	V1="${V1%-inverted}"
	if [ "inverse" = True ]; then
		V1="$V1-inverted"
	fi
	V1="$V1.jpg"
	gconftool -t string -s "$K" "$V1"
else
	C=`gconftool -g "$K2"`
	if [ "$inverse" = True ]; then
		C="#FFFFFFFFFFFF"
	else
		C="#000000000000"
	fi
	gconftool -t string -s "$K2" "$C"
fi
