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 mahatman2 on Sat 12th Feb 01:39 (modification of post by mahtaman2 view diff)
diff | 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. mybreak_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. w = pynotify.Notification("GET TO WORK!", "for %s minutes", image) % option.work_time
  37. p = pynotify.Notification("For %s minutes,", "Take a well-deserved break, dear.", image) % %option.play_time
  38. 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
  39.  
  40. if __name__ == '__main__':
  41.     while option.stop is False:
  42.         w.show()
  43.         time.sleep(work_time)
  44.         p.show()
  45.         time.sleep(play_time)
  46.         w.show()
  47.         time.sleep(work_time)
  48.         p.show()
  49.         time.sleep(play_time)
  50.         w.show()
  51.         time.sleep(work_time)
  52.         p.show()
  53.         time.sleep(play_time)
  54.         w.show()
  55.         time.sleep(work_time)
  56.         b.show()
  57.         time.sleep(break_time)
  58.     n = pynotify.Notification("Done.", "You're done, hurray! Good job.", image)
  59.     n.show()
  60.     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