#!/bin/bash

while(true); do
	if [ "`ping -c 2 -q 147.228.1.1 1>/dev/null; echo $?`" -eq "1" ]; then
		#echo "connectivity lost"
		#plazma
		#DISPLAY=:3 /usr/bin/X11/xset s 1
		#lcd
		DISPLAY=:3 /usr/bin/X11/xset dpms force off
		while [ "`ping -c 2 -q 147.228.1.1 1>/dev/null; echo $?`" -eq "1" ]; do
			sleep 60
		#	echo "bad"
		done
		#echo "reconnected"
		# plazma
		#DISPLAY=:3 /usr/bin/X11/xset s 0 s activate
		# lcd
		DISPLAY=:3 /usr/bin/X11/xset dpms force on
		
		/usr/bin/killall iceweasel
		/usr/bin/killall firefox-bin
	fi
	#echo "ok"
	DISPLAY=:3 /usr/bin/X11/xset -dpms 
	sleep 60
done

