Created
July 26, 2014 15:42
-
-
Save alenbasic/bf86a4b018e2300fd694 to your computer and use it in GitHub Desktop.
A simple script when run pops up with a libnotify notification. Assigned to a keyboard shortcut and works like a charm!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
#!/user/bin/python | |
from gi.repository import Notify; import json; import urllib2; import sys | |
reload(sys); sys.setdefaultencoding("utf-8") | |
city_name = "Insert City Name Here" | |
city_data = json.load(urllib2.urlopen("http://api.openweathermap.org/data/2.5/weather?q="+city_name)) | |
city_temp = str(city_data['main']['temp']-273.15) | |
city_weather = city_data['weather'][0]['description'] | |
Notify.init ("City: " + city_name + " " + city_weather) | |
Hello=Notify.Notification.new ("City: " + city_name, "Weather: " + city_weather + " - Temperature: " + city_temp +"°C","dialog-information") | |
Hello.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment