summaryrefslogtreecommitdiff
path: root/archive/bin/pomodoro
diff options
context:
space:
mode:
Diffstat (limited to 'archive/bin/pomodoro')
-rwxr-xr-xarchive/bin/pomodoro83
1 files changed, 83 insertions, 0 deletions
diff --git a/archive/bin/pomodoro b/archive/bin/pomodoro
new file mode 100755
index 00000000..9bb89df5
--- /dev/null
+++ b/archive/bin/pomodoro
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+
+"""Sean's pomodoro timer
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+"""
+
+import time
+import os
+import sys
+import spw
+
+WORK_MINUTES = 25
+BREAK_MINUTES = 5
+LONG_BREAK_MINUTES = 30
+POMODOROS_BLOCK = 4
+
+def main():
+ """Pomodoro technique loop"""
+ os.system('clear')
+ pomodoros_completed = 0
+ move_on_wait()
+
+ while True:
+ if pomodoros_completed < POMODOROS_BLOCK:
+ count_down(WORK_MINUTES, 'work')
+ pomodoros_completed = pomodoros_completed + 1
+
+ # do a short break unless it's time for a long break,
+ # which'll happen when we break out of the main while loop
+ if pomodoros_completed < POMODOROS_BLOCK:
+ spw.try_audible_notification(str(BREAK_MINUTES)
+ + ' minute break')
+ count_down(BREAK_MINUTES, 'rest')
+ spw.try_audible_notification('Time to start working again')
+ t0 = time.time()
+ move_on_wait()
+ t1 = time.time()
+ # accidental longer break
+ if t1 - t0 > 1200:
+ pomodoros_completed = 0
+ else:
+ spw.try_audible_notification(str(LONG_BREAK_MINUTES)
+ + ' minute break.'
+ ' Go and do something else')
+ count_down(LONG_BREAK_MINUTES, 'rest')
+ pomodoros_completed = 0
+ move_on_wait()
+
+def count_down(total_minutes, kind):
+ """Count down TOTAL_MINUTES of KIND."""
+ left = 0
+ left_string = ''
+
+ for minutes in range(total_minutes):
+ left = total_minutes - minutes
+ left_string = ' minutes' if left > 1 else ' minute'
+ left_string += ' of ' + kind + ' left'
+ spw.print_same_line(str(left) + left_string)
+ try:
+ time.sleep(60)
+ except KeyboardInterrupt:
+ spw.print_same_line()
+ sys.exit()
+
+def move_on_wait():
+ raw_input("Press enter when you are ready to move on")
+ sys.stdout.write("\033[F")
+
+if __name__ == "__main__":
+ main()