#!/bin/bash
sleep 20
cp ~/.conky/conkytemp /tmp/


IP=`curl http://ipecho.net/plain`
echo "IP: $IP"
PLACE=`curl ipinfo.io/$IP 2>&1|grep city|cut -d"\"" -f4`
echo "Lugar: $PLACE"
curl wttr.in/$PLACE 2>&1 >/tmp/weather
TEMP=`cat /tmp/weather|head -n4|tail -n1|cut -c 26-|xargs|sed -r "s:\x1B\[[0-9;]*[mK]::g"|tr -d '[:space:]'`
echo "Temperatura: $TEMP"

test=`echo "$TEMP"|grep "m"`
echo $test

if [ "$test" != "" ];then
    TEMP=`echo "$TEMP"|cut -d"." -f3` 
fi
    rpl -- "Celsius" "$TEMP" /tmp/conkytemp
    IFACE=`/sbin/route|grep default|awk '{print$8}'`
    rpl "eth0" "$IFACE" /tmp/conkytemp


sleep 20;cp /tmp/conkytemp ~/.conkyrc

