#!/usr/bin/bash


xlst ()
{

xrandr |grep -e connected -e \*|sed 's/primary//g'
}
mkcmds ()
{
for mon in `xlst|grep -w connected |awk '{print $1 }' `
do
set `xlst |grep -w $mon `
if [ $# -gt 11 ]
then
 pos=`xlst |grep $mon |cut -d+ -f2,3|awk '{if (NF >11 ) {print $1}}' |sed 's/+/x/g'`
 set ` xlst |grep $mon |cut -d+ -f1 `
 dim=$3
 xmon=$1
 echo "xrandr --output $xmon --mode $dim --pos $pos"
else
 echo "xrandr --output $mon --off"
fi

done
}
# display on stdout
[ $# -eq 0 ] && mkcmds

# save to script and make executable
if [ $# -eq 1 ] 
then 
mkcmds > $1
chmod 755 $1
ls -l $1

fi

