#!/bin/bash

# Test internet
timeout 4 wget -q --spider http://cloogle.org || setbg-backup || exit 1

stdbuf -i0 -o0 -e0 cloogle_stats.py | while read request
do
	if [ "$request" == "Opened connection." ] || [ "$request" == "Lost connection" ]; then
		continue
	fi
	echo "$request" | pygmentize -l clean -O line_numbers=false -o /tmp/bg-cloogle.png
	feh -B white --bg-center /tmp/bg-cloogle.png
done &