Skip to content

Instantly share code, notes, and snippets.

@anroots
Created May 11, 2012 01:17
Show Gist options
  • Save anroots/2656909 to your computer and use it in GitHub Desktop.
Save anroots/2656909 to your computer and use it in GitHub Desktop.
A script to display a random goal from 43things.com in Ubuntu's Notify-OSD. Set it up to start on login and you'll get a new goal every day.
#!/usr/bin/python -tt
# A script to display a random goal from 43things.com in Ubuntu's Notify-OSD. Set it up to start
# on login and you'll get a new goal every day.
# Author: A. Roots
import urllib, sys
from xml.dom import minidom
import random
import pynotify
def main():
print 'Fetching today's tip...'
random.seed()
randomNumber = random.randint(1,3000000)
url = 'http://www.43things.com/service/get_goal_by_id?api_key=2939451@43hKaaBzWkJ8&id='+str(randomNumber)
xmlFile = urllib.urlopen(url).read()
dom = minidom.parseString(xmlFile)
objektid = dom.getElementsByTagName('name')
objekt = objektid[0].toxml()
objekt = objekt[6:]
objekt = objekt[:-7]
n = pynotify.Notification ("You should...", str(objekt))
n.show ()
print 'All done, exiting.'
sys.exit(0)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment