Local weather, wherever you are - Conky script
Wednesday, 28. October 2009, 08:56:15
Here it is:
http://files.myopera.com/coreymwamba/files/weatherscripts.tar.bz2
I'll reproduce the README here...
Local weather scripts by Corey Mwamba
WHAT DOES THIS DO?
This collection of scripts finds out the location of the IP server to which you're connected, and from that it gets your nearest weather station. Then it uses a python-metar script to present the weather to you.
You could use it in a Conky script on a laptop to get the general weather conditions where you are at the time. You could, of course, look out of a window instead: but why would you want to do that when you could have a COOL SCRIPT tell you instead? Eh? Eh?
WHAT YOU NEED TO MAKE THIS WORK
As far as I am aware, you need an Internet connection and:
python-metar - this is the bit that finds out the actual weather! It may be called **pymetar** for your system.
wget - this downloads the various bits of information for the weather.
If you want to use it in a Conky script, you also need Conky.
THE SCRIPTS
iplocfind
This is a script that I did not write, but have modified. It finds out the latitude and longitude of your IP address. I imagine it's not incredibly accurate, but it's good enough here!
I don't think it'll work if you're doing some kind of proxy weirdness (for example, you're in Australia but using an IP address that says you're in Wales - you'll just get weather for Wales).
A bunch of Python scripts (ending in .py)
These are python-metar scripts. weather.py is a script that comes with the RPM, but slightly modified by me. From that script I made separate scripts for temperature, wind, sky conditions and water content/rain.
weather.py
weather-rain.py
weather-sky.py
weather-temp.py
weather-wind.py
a bunch of scripts that begin with the word "local"
These are the scripts I wrote to pull everything together. It sends the latitude and longitude to a JSON site on Geonames - it's this that finds your nearest weather station. The script then strips that output to just the ICAO code for the weather station and feeds this to the appropriate Python script.
localrain
localsky
localtemp
localweather
localwind
locality
It is these that you would call in a Conky script, but you can use them as commands:
Example - open up a terminal, and find out what the weather's like.
corey@corlap:~> localweather Temperature: 12.0°C Rel. Humidity: 87% gentle breeze Wind speed: 3.58 m/s (3 Bft) Wind direction: 200 deg (SSW) Pressure: 1015 hPa Dew Point: 10.0 C / 50.0 F Weather: Few clouds Sky Conditions: mostly clear Visibility: None
conky-local-weather
I've included an example Conky script, to show how it works.
HOW TO INSTALL
Unpack the archive - the scripts are all executable so it should "JUST WORK".
If you grab them from here, you'll have to make them executable. Here's how:
If you don't want to use a terminal
- pop open your file browser and go to the folder where you saved the scripts
- select all the scripts except conky-local-weather
- Use the File Properties or Properties menu item. In most graphical file browsers you can right click on the mouse and this will be listed in the menu
- Go to the Permissions tab and tick/fill the Execute box for the Owner, Group and Others
- Accept your changes - probably by selecting the OK button
using a terminal
cd /path/to/weatherscripts/ chmod a+x * chmod a-x conky-local-weather
Either way is fine.
If you like, you can move them (as root) to /usr/bin BUT THERE'S REALLY NO NEED TO DO SO.
IF YOU'VE GOT A PROBLEM
I'm probably not the best person to fix it. I'm not actually a programmer and don't really understand a lot about script programming. I'm not even entirely certain I've chosen the most efficient way of doing this - it's just the way that makes most sense to me with the limited skills I have.
In short: it's unlikely I'm going to be able to help you. But I'll give it a go.
IF YOU CAN DO THIS BETTER
Then please feel free to do so.









