Created
January 7, 2012 14:35
-
-
Save vsr/1574905 to your computer and use it in GitHub Desktop.
PyNotify
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
| 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