import os
import subprocess
import time
name=subprocess.check_output(['machinename'])
while True:
	#output=subprocess.check_output(['export DISPLAY=:0'])
	#output=subprocess.check_output(['export', 'DISPLAY=:0','&&','export' 'XAUTHORITY=/home/pi/.Xauthority'])
	#print(name)
	outpu=os.popen('rm /home/pi/pantalla/'+name.decode('utf-8')[:-1]+'.png')
	salida='export DISPLAY=:0 && export XAUTHORITY=/home/pi/.Xauthority && scrot -bu /home/pi/pantalla/'+name.decode('utf-8')[:-1]+'.png'
	print(salida)
	output=os.popen(salida)
	output=os.popen('sudo scp -i /etc/eye3/ssh_key_robot /home/pi/pantalla/'+name.decode('utf-8')[:-1]+'.png robot@mother.eye3.cl:/home/robot/pantallas/'+name.decode('utf-8')[:-1]+'.png')
	time.sleep(60)
