#!/bin/bash
# toggledesktop by Katja (fly5.kapsi.fi)
# got the idea and very nice launcher icon from the site
# http://tinyurl.com/qsomhb

if [[ "`gconftool --get /apps/nautilus/preferences/show_desktop`" == "true" ]]; then
	gconftool --set /apps/nautilus/preferences/show_desktop \
	 --type boolean false
else
	gconftool --set /apps/nautilus/preferences/show_desktop \
	 --type boolean true

	# thanks Janne for the -n tip, no more pop-up window
	nautilusstatus="`pidof nautilus >&-; echo $?`"
	[[ "$nautilusstatus" == "1" ]] && nautilus -n &
fi

# EOF

# if you want to monitor the status, you can try this:
# while true; do
# 	clear
# 	echo -e "`date`\n"
# 	DESKSTAT="`gconftool --get /apps/nautilus/preferences/show_desktop`"
# 	NAUTSTAT="`pidof nautilus >&- && echo true || echo false`"
# 	echo -e "SHOW DESKTOP STATUS: \t$DESKSTAT"; 
# 	echo -e "NAUTILUS STATUS: \t$NAUTSTAT"
# 	sleep 1
# done