xrandr is an intefrace to the RandR extension. xrandr, the width and height of the screen can be determined in a shell script like so w=$(xrandr | grep current | awk '{tmp=($8 *1); print tmp}')
h=$(xrandr | grep current | awk '{tmp=($10*1); print tmp}')
echo Screen is $w pixels wide and $h pixels high
xrandr --output VGA1 --auto --output HDMI1 --auto --right-of VGA1