#!/bin/bash

# togglepanel.sh v1.02 (12th november 2010)
# birdslikewires.co.uk
#  Toggles the visibility of any full screen width panels on the Gnome desktop.

RES=`xrandr -display :0 2>/dev/null | grep current | awk -F\current\  '{print $2}' | awk -F\ x '{print $1}'`
WID=`xdotool search -class "gnome-panel"`
for i in ${WID}; do
	INFO=`xwininfo -id $i 2>/dev/null`
	if [[ "$INFO" =~ "Width: $RES" ]]; then
		if [ "$1" == "" ]; then
			if [[ "$INFO" =~ "IsViewable" ]]; then
				xdotool windowunmap $i
			elif [[ "$INFO" =~ "IsUnMapped" ]]; then
				xdotool windowmap $i
			fi
		elif [ "$1" == "hide" ]; then
			xdotool windowunmap $i
		elif [ "$1" == "show" ]; then
			xdotool windowmap $i
		fi
	fi
done
exit 0
