CrunchBang Linux Pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

CrunchBang Linux Pastebin

Posted by mahtaman2 on Fri 11th Feb 06:17 (modification of post by view diff)
View followups from mahatman2 | download | new post

  1. #!/usr/bin/env python
  2. # pomodoro v0.2, the PYTHON version, with images!
  3. # by Case Duckworth (mahatman2), mahatman2@gmail.com
  4. # with help from cb-fortune
  5. # a technique for Getting Things Done.
  6.  
  7. import pygtk
  8. pygtk.require('2.0')
  9. import pynotify
  10. import sys
  11. import gtk
  12. import os
  13. import string
  14. import time
  15. from optparse import OptionParser
  16.  
  17. # Options
  18. parser = OptionParser()
  19. parser.set_defaults(work_time=25, play_time=5, break_time=20)
  20. parser.add_option("-w", "--work-time", type="int", dest="work_time",
  21.                   help="how much time to work, in minutes")
  22. parser.add_option("-p", "--play-time", type="int", dest="play_time",
  23.                   help="how much time to break, in minutes")
  24. parser.add_option("-b", "--break-time", type="int", dest="break_time",
  25.                   help="how long the longer break is, in minutes")
  26. parser.add_option("--stop", dest="stop", action="store_true", default=False)
  27. (option, args) = parser.parse_args()
  28.  
  29. # VARS
  30. work_time = option.work_time # * 60 #put it in seconds for time.sleep
  31. play_time = option.play_time #* 60
  32. break_time = option.break_time# * 60
  33. image = "/home/case/bin/pomodoro.png"
  34.  
  35. # some initial setup. This is the part that I bet could use some cleaning!
  36. class work():
  37.     title = "GET TO WORK!"
  38.     message = "for %s minutes" % option.work_time
  39. w = pynotify.Notification(work.title, work.message, image)
  40. class play():
  41.     title = "For %s minutes," % option.play_time
  42.     message = "Take a well-deserved break, dear."
  43. p = pynotify.Notification(play.title, play.message, image)
  44. class mybreak():
  45.     title = "Take a long break."
  46.     message = "It's time for a %s break. So chill for a bit, but be back soon!" % option.break_time
  47. b = pynotify.Notification(mybreak.title, mybreak.message, image)
  48.  
  49. if __name__ == '__main__':
  50.     while option.stop is False:
  51.         w.show()
  52.         time.sleep(work_time)
  53.         p.show()
  54.         time.sleep(play_time)
  55.         btog = " BACK "
  56.         btog2 = " another "
  57.         w.show()
  58.         time.sleep(work_time)
  59.         p.show()
  60.         time.sleep(play_time)
  61.         w.show()
  62.         time.sleep(work_time)
  63.         p.show()
  64.         time.sleep(play_time)
  65.         w.show()
  66.         time.sleep(work_time)
  67.         b.show()
  68.         time.sleep(break_time)
  69.     n = pynotify.Notification("Done.", "You're done, hurray! Good job.", image)
  70.     n.show()
  71.     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.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me