Note: I’ve made an entire new system running from a database that can accommodate multiple rotating outputs, because I liked seeing the webcams so much on my tv along with my own cctv. I leave this here as an idea script. btw, there was an update for 3 monitors based on the below that used this very script, but I’m going to jump straight to the database one as it’s much better.
I had the idea to include some public webcams onto my zoneminder monitor, I’m already running xlib_shm so was considering find a way within that code to pickup some jpegs and display them in one area. However this seemed overly complicated, it seemed a much simpler idea to create a new monitor in zoneminder that picks up from a local file and just add that monitor onto the xlib_shm line in the xinitrc file so it displays on bootup.
#!/bin/bash
DIR=/var/cache/zoneminder/webcams
PULLINTERVAL=300
ROTATEINTERVAL=13
CHECKINTERVAL=300
NEXTPULL=0
NEXTROTATE=0
NEXTXLIBCHECK=0
CURRENTIMAGE=1
echo Directory : $DIR
echo Pull Interval : $PULLINTERVAL
echo Rotate Interval : $ROTATEINTERVAL
cd $DIR
geturls()
{
FILENO=0
for i in `cat $DIR/urls.txt`
do
FILENO=$[$FILENO+1]
wget -q $i -O $FILENO.jpg
done
NEXTPULL=$[$DATE+$PULLINTERVAL]
}
rotateimage()
{
convert $CURRENTIMAGE.jpg -resize 640x480! rotate.jpg
if [ "$CURRENTIMAGE" -eq "$FILENO" ]; then
CURRENTIMAGE=1
else
CURRENTIMAGE=$[$CURRENTIMAGE+1]
fi
NEXTROTATE=$[$DATE+$ROTATEINTERVAL]
}
checkxlib()
{
PGREPXLIB=`pgrep xlib_shm`
if [ -z $PGREPXLIB ]; then
startx &
fi
NEXTXLIBCHECK=$[$DATE+$CHECKINTERVAL]
}
while true; do
DATE=`date +%s`
if [ "$DATE" -gt "$NEXTPULL" ]; then
geturls
fi
if [ "$DATE" -gt "$NEXTROTATE" ]; then
rotateimage
fi
if [ "$DATE" -gt "$NEXTXLIBCHECK" ]; then
checkxlib
fi
sleep 2
done