Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > 13f5dcef5358e9d5a2a5a1ae6baf28fc > files > 125

gtkdialog-0.8.3-1.mga5.x86_64.rpm

#!/bin/sh

## Includes.
. funcrcSet

## Save window dimensions.
## On entry: $1 = window title

funcWindowDimSave() {
	if [ -z "$BASH" ]; then local FUNCNAME=funcWindowDimSave; fi
	if [ $DEBUG_TRANSITS -ne 0 ]; then echo "$FUNCNAME(): IN"; fi

	## Local variables.
	local line width height
	local found=0

	## This is the recommended portable way to check for
	## the existence of an executable within the path.
	if [ `command -v xwininfo` ]; then

		## xwininfo returns stats by default but it'll print info if
		## the named window exists or not so this must be checked for.
		xwininfo -name "$1" > $TEMP_DIR/XWinInfo
		while read -r line; do
			case $line in
				xwininfo:*\"$1\")
					found=1 ;;
				Width:*)
					## Get text after first ':'
					width=${line#*:} ;;
				Height:*)
					## Get text after first ':'
					height=${line#*:} ;;
			esac
		done < $TEMP_DIR/XWinInfo

		if [ $found -eq 1 ]; then
			funcrcSet WindowWidth $width
			funcrcSet WindowHeight $height
		fi
	else
		echo "$FUNCNAME(): xwininfo is required to save the window dimensions."
	fi

	if [ $DEBUG_TRANSITS -ne 0 ]; then echo "$FUNCNAME(): OUT"; fi
}