Skip to content

Instantly share code, notes, and snippets.

@vsr
Created January 7, 2012 14:35
Show Gist options
  • Save vsr/1574905 to your computer and use it in GitHub Desktop.
Save vsr/1574905 to your computer and use it in GitHub Desktop.
PyNotify
import os, sys
import datetime, time
import pynotify
# Notifies with a fortune cookie every X minutes.
# Usage: "python notifyme.py 10" to notify every 10 minutes
def notify(count):
fortune = os.popen('fortune -n 100 -s', 'r').read()
time = datetime.datetime.now().strftime("%H:%M:%S")
pynotify.Notification("%s (%s) >>" % (time,count) , fortune).show()
if __name__ == "__main__":
pynotify.init('Notify Me')
try:
interval = float(sys.argv[1])
except:
interval = 20
notification_count = 0
try:
while True:
notification_count+=1
notify(notification_count)
time.sleep(interval*60)
except (KeyboardInterrupt, SystemExit):
print "\nNotified %s times." % notification_count
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment