Created
April 10, 2010 21:54
-
-
Save mrtazz/362323 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env python | |
# | |
# simple timer for pomodoro like counting | |
# Usage: pomodoro.py WORKTIME BREAKTIME | |
# | |
import sys | |
import os | |
from time import gmtime, strftime, sleep | |
def main(e,b): | |
""" main function """ | |
end = float(e) * 60 | |
print "Let's do %1.0f minutes of hard work." % (end/60) | |
countdown(end) | |
os.system('growlnotify -m "Time for a break" -t "pomodoro.py"') | |
breaktime = float(b) * 60 | |
print "\nAllright, %1.0f minute break." % (breaktime/60) | |
countdown(breaktime) | |
os.system('growlnotify -m "Break is over, ready for another round?" \ | |
-t "pomodoro.py"') | |
def countdown(t): | |
""" function to countdown the given time """ | |
now = 0 | |
while (now <= t): | |
s = "\b\b\b\b\b\b%s" % strftime("%M:%S", gmtime(now)) | |
print s, | |
sys.stdout.flush() | |
now += 1 | |
sleep(1) | |
if __name__ == '__main__': | |
e = 25 | |
b = 5 | |
if len(sys.argv) >= 2: e = sys.argv[1] | |
if len(sys.argv) >= 3: b = sys.argv[2] | |
main(e,b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment