#! /bin/sh
### BEGIN INIT INFO
# Provides:          automode
# Should-Start:      
# Required-Start:    lightdm
# Required-Stop:     lightdm
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: automode
# Description:       automode
### END INIT INFO
#
# Author:       zxr 
#              
#
setmode()
{
	max_x=`cat /sys/module/goodix_gt9xx/parameters/max_x`
	max_y=`cat /sys/module/goodix_gt9xx/parameters/max_y`
	echo max_x=$max_x>>/root/sc.log
	echo max_y=$max_y>>/root/sc.log
	echo `id` >> /root/sc.log
	
	# 需要  等lightdm启动后才能xrandr
	sleep 3
	if [ $max_x = 1024 -a $max_y = 600 ];then
		XAUTHORITY=/home/linaro/.Xauthority DISPLAY=:0.0 xrandr -s 1024x600p60 >> /root/sc.log 2>&1
	elif [ $max_x = 1280 -a $max_y = 800 ];then
		XAUTHORITY=/home/linaro/.Xauthority DISPLAY=:0.0 xrandr -s 1280x800p60 >> /root/sc.log 2>&1
	fi
	echo automode `date +%M:%S.%N` >> /root/sc.log
	#printenv > /root/sc.log
}
case "$1" in
  start)
	  setmode
  ;;
  stop)
  ;;
  reload)
	  setmode
  ;;
  status)
  ;;
  restart|force-reload)
        $0 stop
        sleep 1
        $0 start
  ;;
  *)
        echo "Usage: /etc/init.d/automode {start|stop|restart|reload|force-reload|status}"
        exit 1
  ;;
esac

exit 0
