Skip to content

Instantly share code, notes, and snippets.

@Svenito
Created June 28, 2012 08:31
Show Gist options
  • Save Svenito/3009923 to your computer and use it in GitHub Desktop.
Save Svenito/3009923 to your computer and use it in GitHub Desktop.
Weather desktop
#!/usr/bin/python
import sys
import pywapi
import subprocess
img_path = "/path/to/img/weather/"
weather_img = {}
weather_img['Partly Sunny'] = img_path + "part_sun.jpg"
weather_img['Scattered Thunderstorms'] = img_path + "thunder.jpg"
weather_img['Showers'] = img_path + "shower.jpg"
weather_img['Scattered Showers'] = img_path + "rain.jpg"
weather_img['Rain and Snow'] = img_path + "rain_snow.jpg"
weather_img['Overcast'] = img_path + "overcast.jpg"
weather_img['Light Snow'] = img_path + "light_snow.jpg"
weather_img['Freezing Drizzle'] = img_path + "freez_drizzle.jpg"
weather_img['Chance of Rain'] = img_path + "rain.jpg"
weather_img['Sunny'] = img_path + "sunny.jpg"
weather_img['Clear'] = img_path + "clear.jpg"
weather_img['Mostly Sunny'] = img_path + "part_sun.jpg"
weather_img['Partly Cloudy'] = img_path + "part_cloud.jpg"
weather_img['Mostly Cloudy'] = img_path + "most_cloud.jpg"
weather_img['Chance of Storm'] = img_path + "chance_storm.jpg"
weather_img['Rain'] = img_path + "rain.jpg"
weather_img['Chance of Snow'] = img_path + "chance_snow.jpg"
weather_img['Cloudy'] = img_path + "cloudy.jpg"
weather_img['Mist'] = img_path + "mist.jpg"
weather_img['Storm'] = img_path + "storm.jpg"
weather_img['Thunderstorm'] = img_path + "thunder.jpg"
weather_img['Chance of TStorm'] = img_path + "thunder.jpg"
weather_img['Sleet'] = img_path + "sleet.jpg"
weather_img['Snow'] = img_path + "snow.jpg"
weather_img['Icy'] = img_path + "icy.jpg"
weather_img['Dust'] = img_path + "dust.jpg"
weather_img['Fog'] = img_path + "fog.jpg"
weather_img['Smoke'] = img_path + "smoke.jpg"
weather_img['Haze'] = img_path + "haze.jpg"
weather_img['Flurries'] = img_path + "flurry.jpg"
weather_img['Light Rain'] = img_path + "light_rain.jpg"
weather_img['Snow Showers'] = img_path + "snow_shower.jpg"
weather_img['Hail'] = img_path + "hail.jpg"
def updateDesktop():
res = pywapi.get_weather_from_google("london")
cond = res['current_conditions']['condition']
print cond
subprocess.call(['fbsetbg', weather_img[cond]])
if __name__ == "__main__":
updateDesktop()
@Svenito
Copy link
Author

Svenito commented Jun 28, 2012

Related: Blog post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment