#!/bin/bash
set -x

rm -rf ~/Images/tmp/*
mkdir -p ~/Images/Trombines
mkdir -p ~/Images/tmp

cd /home/ubuntu/Images

metapixel-prepare --recurse ~/Images/Trombines/ ~/Images/tmp 
metapixel --library ~/Images/tmp --cheat=10 --width=51 --heigh=38  --distance=2 --metapixel ~/Images/librairielogo.jpg ~/Images/mosaic.png 
killall gthumb
gthumb -f ~/Images/mosaic.png &

while true
do
#ls ~/Images/Webcam/* 2>&1 > /dev/null
ls /mnt/Partage/Webcam/* 2>&1 > /dev/null
RET=$?
if [ "$RET" -eq 0 ]
then
	cp /mnt/Partage/Webcam/* ~/Images/Trombines
	mv /mnt/Partage/Webcam/* /mnt/Partage/Trombines

	metapixel-prepare --recurse ~/Images/Trombines/ ~/Images/tmp 
	metapixel --library ~/Images/tmp --cheat=10 --width=51 --heigh=38  --distance=2 --metapixel ~/Images/librairielogo.jpg ~/Images/mosaic.png 

#	killall gthumb
#	gthumb -f ~/Images/mosaic.png &

fi
sleep 10
done
