#!/bin/bash
#########################################################
#                                                       #
#  Check for new updates  (set on/off in settings.ini)  #
#                                                       #
#  DO NOT CHANGE IN HERE !!!                            #
#                                                       #
#########################################################

if [ -f "../settings.ini" ]; then
  echo -e "\n$(basename $0): \e[31mOnly works when started via conky!\e[m\n" > /dev/stderr
  exit
fi

if [ -f "./settings.ini" ]; then
  source "./settings.ini"
else
  echo -e "\n$(basename $0): \e[31mNo settings.ini found!\e[m\n" > /dev/stderr
  pkill -f forecast.conky
  exit
fi

if [ "$showupdates" = "yes" ]; then
  curl -s "www.cobrasoft.nl/download/conky/flipclock-weather/updates" -o ./json/updates.tmp
  newversion=$(cat ./json/updates.tmp | awk -F'=' '{print $2}')
  if [ $newversion \> $version ]; then
     #echo -e "\n\e[32m New update available!\e[m   See README.TXT for more info\n" > /dev/stderr
     echo -e "     "
  fi
fi

rm -f ./json/updates.tmp
