Posted by mahatman2 on Sat 12th Feb 01:39 (modification of post by mahtaman2 view diff)
diff | download | new post
- #!/usr/bin/env python
- # pomodoro v0.2, the PYTHON version, with images!
- # by Case Duckworth (mahatman2), mahatman2@gmail.com
- # with help from cb-fortune
- # a technique for Getting Things Done.
- import pygtk
- pygtk.require('2.0')
- import pynotify
- import sys
- import gtk
- import os
- import string
- import time
- from optparse import OptionParser
- # Options
- parser = OptionParser()
- parser.set_defaults(work_time=25, play_time=5, break_time=20)
- parser.add_option("-w", "--work-time", type="int", dest="work_time",
- help="how much time to work, in minutes")
- parser.add_option("-p", "--play-time", type="int", dest="play_time",
- help="how much time to break, in minutes")
- parser.add_option("-b", "--break-time", type="int", dest="break_time",
- help="how long the longer break is, in minutes")
- parser.add_option("--stop", dest="stop", action="store_true", default=False)
- (option, args) = parser.parse_args()
- # VARS
- work_time = option.work_time # * 60 #put it in seconds for time.sleep
- play_time = option.play_time #* 60
- mybreak_time = option.break_time# * 60
- image = "/home/case/bin/pomodoro.png"
- # some initial setup. This is the part that I bet could use some cleaning!
- w = pynotify.Notification("GET TO WORK!", "for %s minutes", image) % option.work_time
- p = pynotify.Notification("For %s minutes,", "Take a well-deserved break, dear.", image) % %option.play_time
- b = pynotify.Notification("Take a long break.", "It's time for a %s break. So chill for a bit, but be back soon!", image) % mybreak_time
- if __name__ == '__main__':
- while option.stop is False:
- w.show()
- time.sleep(work_time)
- p.show()
- time.sleep(play_time)
- w.show()
- time.sleep(work_time)
- p.show()
- time.sleep(play_time)
- w.show()
- time.sleep(work_time)
- p.show()
- time.sleep(play_time)
- w.show()
- time.sleep(work_time)
- b.show()
- time.sleep(break_time)
- n = pynotify.Notification("Done.", "You're done, hurray! Good job.", image)
- n.show()
- os.popen("pkill -9 -f pomodoro.py")
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.