Update pomodoro script (repeats)
							parent
							
								
									6ec53feabc
								
							
						
					
					
						commit
						4fbdacb859
					
				
							
								
								
									
										39
									
								
								.bin/pomo
								
								
								
								
							
							
						
						
									
										39
									
								
								.bin/pomo
								
								
								
								
							| 
						 | 
					@ -20,23 +20,38 @@ atexit.register(clear)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
parser = ArgumentParser()
 | 
					parser = ArgumentParser()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					parser.add_argument('-p', '--prep-duration', type=int, help='Preparation duration of a session', default=0)
 | 
				
			||||||
parser.add_argument('-w', '--work-duration', type=int, help='Duration of a session', default=25)
 | 
					parser.add_argument('-w', '--work-duration', type=int, help='Duration of a session', default=25)
 | 
				
			||||||
parser.add_argument('-b', '--break-duration', type=int, help='Duration of a break', default=5)
 | 
					parser.add_argument('-b', '--break-duration', type=int, help='Duration of a break', default=5)
 | 
				
			||||||
 | 
					parser.add_argument('-r', '--repeats', type=int, help='Numer of sessions', default=1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
args = parser.parse_args()
 | 
					args = parser.parse_args()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
work_duration = args.work_duration * 60
 | 
					prep_duration  = args.prep_duration * 60
 | 
				
			||||||
 | 
					work_duration  = args.work_duration * 60
 | 
				
			||||||
break_duration = args.break_duration * 60
 | 
					break_duration = args.break_duration * 60
 | 
				
			||||||
 | 
					repeats = args.repeats
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def countdown(duration):
 | 
					def make_countdown(color):
 | 
				
			||||||
  while duration!= 0:
 | 
					  def countdown(duration):
 | 
				
			||||||
    mins = duration // 60
 | 
					    while duration!= 0:
 | 
				
			||||||
    secs = duration % 60
 | 
					      mins = duration // 60
 | 
				
			||||||
    os.system('echo -n \x03 "{:02d}:{:02d} \x01" > /tmp/pomo'.format(mins, secs))
 | 
					      secs = duration % 60
 | 
				
			||||||
    sleep(1)
 | 
					      os.system('echo -n "{:s} {:02d}:{:02d} \x01" > /tmp/pomo'.format(color, mins, secs))
 | 
				
			||||||
    duration -= 1
 | 
					      sleep(1)
 | 
				
			||||||
 | 
					      duration -= 1
 | 
				
			||||||
 | 
					  return countdown
 | 
				
			||||||
 | 
					
 | 
				
			||||||
countdown(work_duration)
 | 
					prep_countdown  = make_countdown("\x01")
 | 
				
			||||||
notification.notify(title="Time for a break")
 | 
					work_countdown  = make_countdown("\x03")
 | 
				
			||||||
countdown(break_duration)
 | 
					break_countdown = make_countdown("\x02")
 | 
				
			||||||
notification.notify(title="Break is over, set a new timer")
 | 
					
 | 
				
			||||||
 | 
					prep_countdown(prep_duration)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					while repeats!=0:
 | 
				
			||||||
 | 
					  notification.notify(title="Get started")
 | 
				
			||||||
 | 
					  work_countdown(work_duration)
 | 
				
			||||||
 | 
					  notification.notify(title="Time for a break")
 | 
				
			||||||
 | 
					  break_countdown(break_duration)
 | 
				
			||||||
 | 
					  notification.notify(title="Break is over, set a new timer")
 | 
				
			||||||
 | 
					  repeats-=1
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue