#!/bin/sh

#pixelsize of one screen
X=1024
Y=768
#leave as it is
X_OFFSET=0
Y_OFFSET=0
#taskbar, leave empty for none
TASKBAR=1
#size of the taskbar if there is one
TASKBAR_SIZE=25
#where is the taskbar located top or bottom
TASKBAR_POSITION="bottom"
#none, dualhead or quadhead
DUALHEAD="dualhead"
#on which screen
SCREEN=$1
#if theres quadshead mode active, are the screens ordered from left to right
#or a big cube leave blank for left to right
QUBE=1
#i had some pixel distortion on the screen while testing, trying to compensate them
DISTORTION=3

function subtractTaskbar {
	if [  ! -z $TASKBAR ]; then
		let Y=$Y-$TASKBAR_SIZE
	fi
	if [ "x$TASKBAR_POSITION" = "xtop" ]; then
		let Y_OFFSET=$Y_OFFSET+$TASKBAR_SIZE
	fi
}


if [ "x$DUALHEAD" = "xdualhead" ]; then
	case $SCREEN in
		2)
			let X_OFFSET=$X
		;;
		*)
			subtractTaskbar
		;;
	esac
elif [ "x$DUALHEAD" = "xquadhead" ]; then
	if [ ! -z $QUBE ]; then
		case $SCREEN in
			4)
				let Y_OFFSET=$Y
				let X_OFFSET=$X
				subtractTaskbar
			;;
			3)
				let Y_OFFSET=$Y
				let X=$X-$DISTORTION
				let Y=$Y-$DISTORTION
				subtractTaskbar
			;;
			2)
				let X_OFFSET=$X
				let Y=$Y-$DISTORTION
			;;
			all)
				let X=($X*2);
				let Y=($Y*2);
			;;
			*)
				let X=$X-$DISTORTION
				let Y=$Y-$DISTORTION
			;;
		esac
	else 
		case $SCREEN in
			4)
				let X_OFFSET=($X*3)
				let X=$X-$DISTORTION
			;;
			3)
				let X_OFFSET=($X*2)
				let X=$X-$DISTORTION
			;;
			2)
				let X_OFFSET=$X
				let X=$X-$DISTORTION
				subtractTaskbar
			;;
			all)
				let X=($X*4)
				subtractTaskbar
			;;
			*)
				let X=$X-$DISTORTION
				subtractTaskbar
			;;
		esac
	fi
else
	subtractTaskbar
fi

echo $X"x"$Y"+"$X_OFFSET"+"$Y_OFFSET
