mrmierzejewski / conkyrc

Sample Conky (system monitor) configuration file with weather, CPU graph, memory graph, network traffic graph and processes
139 stars 54 forks source link

Location for weather #1

Open ymkim92 opened 10 years ago

ymkim92 commented 10 years ago

Hi zenzire,

You may know the w for weather location from: http://weather.yahooapis.com/forecastrss?**w=493776**&u=c

It will be great if you add some note on README.md for how to change a location from this site https://weather.yahoo.com/

Regards, Young

ghost commented 9 years ago

Yeah, would be great to add autolocation finding too.

I just cobbled this together, its silly how hard in linux it is to find a location now.

This uses your ip to find your WOEID.

Just place this in a file like whereami, chmod u+x whereami

And then you should be good to go. I will now try to add this to your conky script.

###

#!/bin/bash

# use your ip to find your location, and then post out a WOEId
# THANKS TO YAHOO

MY_IP=$(curl -s ifconfig.co)
MY_LOC=$(curl -s ipinfo.io/$MY_IP/loc)
ARR_LOC=(${MY_LOC/,/ })

# LAT  echo ${ARR_LOC[0]}
# LONG echo ${ARR_LOC[1]}

WOEID="`curl --silent http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20geo.placefinder%20where%20text%3D%22${ARR_LOC[0]}%2C${ARR_LOC[1]}%22%20and%20gflags%3D%22R%22 | grep '<woeid>' | sed -e 's|^.*<woeid>\(.*\)</woeid>.*$|\1|'`"
echo $WOEID

Next

create something like;

getweatherrss
chmod u+x getweatherrss

In the conkyrc script, replace the line:

${execi 300 ~/bin/getweatherrss > ~/.cache/weather.xml}

with:

${execi 300 ~/bin/getweather" -o ~/.cache/weather.xml}
ghost commented 9 years ago

Ok, figured it out. That should get pretty close to your location, and all depends upon you having a web connection which the weather requires anyway...and, no need for an API key.

ghost commented 9 years ago

Do you want a patch to this? I found another bug in your greps too...

mrmierzejewski commented 9 years ago

@rejon, thank you for your suggestions. Please propose your fix and I will merge it with my code.

jvault commented 8 years ago
# Soucers #
# Start get a location
${execi 3600 curl -s "https://weather.yahoo.com/_xhr/get-current-location/" -o ~/.cache/weather/auto-location}
\
# end get location
# Start get a weather
${execi 900 curl -s "http://weather.yahooapis.com/forecastrss?w=$(grep -o -E "\"woeid\":[0-9]{6,8}," ~/.cache/weather/auto-location | grep -o -E "[0-9]{6,8}")&u=c" -o ~/.cache/weather/weather.xml}
\
# end get weather
# Start set a weather 
# (Optional: known location watch https://settings.yahoo.com/locations)
#\
# ${execi 900 curl -s "http://weather.yahooapis.com/forecastrss?w=148899&u=c" -o ~/.cache/weather/weather.xml}
#\
# end set weather

I did like that, but not perfect woeid is no presice could be inexacta location. I change files ~ / .cache / to ~ / .cache / weather /)