#!/bin/bash
#
# Suggest you put this script into you home directory, eg 
# mkdir -p ~/bin
# gedit ~/bin/atiscan
# copy paste this in
# chmod +x ~/bin/atiscan


# CONFIG STUFF YOU WILL EDIT
# You can let the script query you for this stuff, though once you have run it once, 
# suggest you edit the script and hard code the settings
DISPLAY_TYPE='dfp1'
WIDTH=1920	
HEIGHT=1080

# SCRIPT STARTS

if [ "" == "$WIDTH" ]
then
	echo "please enter your display width (eg 1280, 1920 etc)"
	read WIDTH
fi
if [ "" == "$WIDTH" ] 
then
	echo "empty widt, dying"
	exit 1
fi
if [ "" == "$HEIGHT" ]
then
	echo "please enter your display width (eg 1280, 1920 etc)"
	read HEIGHT
fi
if [ "" == "$HEIGHT" ] 
then
	echo "empty height, dying"
	exit 1
fi

# DISPLAY TYPE
if [ "" == "$DISPLAY_TYPE" ] 
then
	echo "First we need to check which type of display it is"
	types="crt1 lvds tv cv tmds1 crt2 tmds2 tmds2i dfp1 dfp2 dfp3 dfp4 dfp5 dfp6"
	for t in $types
	do
		aticonfig --query-dispattrib=$t,positionX  
	done
	echo"

	The one that didnt error is the right one

	If you are running more than one monitor/display then take your pick!

	"
	echo "Please enter the one you want to set to $WIDTH x $HEIGHT"
	read DISPLAY_TYPE	
fi


if [ "" == "$DISPLAY_TYPE" ] 
then
	echo "empty display type, dying"
	exit 1
fi


#POSITION
aticonfig --set-dispattrib=$DISPLAY_TYPE,positionX:0
aticonfig --set-dispattrib=$DISPLAY_TYPE,positionY:0
aticonfig --set-dispattrib=$DISPLAY_TYPE,sizeX:$WIDTH
aticonfig --set-dispattrib=$DISPLAY_TYPE,sizeY:$HEIGHT