Add ability to use w/out GUI (via --no-gui)
And ring the console bell w/--noisy
This commit is contained in:
parent
a9b6d3ca99
commit
5c111e96f1
1 changed files with 27 additions and 5 deletions
|
@ -15,6 +15,7 @@ SHORT_MIN = 5 # Minutes for a short break
|
||||||
LONG_MIN = 15 # Minutes for a long break (NOT YET IMPLEMENTED)
|
LONG_MIN = 15 # Minutes for a long break (NOT YET IMPLEMENTED)
|
||||||
INTERRUPTED_MIN = 1 # Minimum minutes to ask to record an interrupted Pomodoro
|
INTERRUPTED_MIN = 1 # Minimum minutes to ask to record an interrupted Pomodoro
|
||||||
QUIET = True
|
QUIET = True
|
||||||
|
GUI = True
|
||||||
|
|
||||||
def pomodoro_prompt_plan(whatdid = ''):
|
def pomodoro_prompt_plan(whatdid = ''):
|
||||||
""" Ask about what task will be worked on (showing last thing worked on)
|
""" Ask about what task will be worked on (showing last thing worked on)
|
||||||
|
@ -22,7 +23,11 @@ def pomodoro_prompt_plan(whatdid = ''):
|
||||||
text = "What're you gonna do?"
|
text = "What're you gonna do?"
|
||||||
# NOTE: If we can do system notifications that when clicked will focus the terminal
|
# NOTE: If we can do system notifications that when clicked will focus the terminal
|
||||||
# running pomodoro prompt, that might be even better than the pop-up GUI text entry.
|
# running pomodoro prompt, that might be even better than the pop-up GUI text entry.
|
||||||
|
if GUI:
|
||||||
whatnext = prompt_window.prompt(prompt=text, task=whatdid)
|
whatnext = prompt_window.prompt(prompt=text, task=whatdid)
|
||||||
|
else:
|
||||||
|
print(f'\n{text}')
|
||||||
|
whatnext = (input(f'({whatdid}): ' if whatdid else '').strip() or whatdid)
|
||||||
# Pressing cancel returns None, but we want to just treat it as an empty string.
|
# Pressing cancel returns None, but we want to just treat it as an empty string.
|
||||||
if whatnext is None:
|
if whatnext is None:
|
||||||
whatnext = ''
|
whatnext = ''
|
||||||
|
@ -32,7 +37,11 @@ def pomodoro_prompt_report(whatnext):
|
||||||
""" Ask what task was completed, showing the last task claimed to be being worked on
|
""" Ask what task was completed, showing the last task claimed to be being worked on
|
||||||
"""
|
"""
|
||||||
text = "What'd you do?"
|
text = "What'd you do?"
|
||||||
|
if GUI:
|
||||||
whatdid = prompt_window.prompt(prompt=text, task=whatnext)
|
whatdid = prompt_window.prompt(prompt=text, task=whatnext)
|
||||||
|
else:
|
||||||
|
print(f'\n{text}')
|
||||||
|
whatdid = (input(f'({whatnext}): ' if whatnext else '').strip() or whatnext)
|
||||||
# Pressing cancel returns None, but we want to just treat it as an empty string.
|
# Pressing cancel returns None, but we want to just treat it as an empty string.
|
||||||
if whatdid is None:
|
if whatdid is None:
|
||||||
whatdid = ''
|
whatdid = ''
|
||||||
|
@ -107,8 +116,22 @@ def prepare_file(utc_start, ext='csv', daily=False):
|
||||||
timelog_path += '.' + ext
|
timelog_path += '.' + ext
|
||||||
return timelog_path
|
return timelog_path
|
||||||
|
|
||||||
|
def bing():
|
||||||
|
if GUI:
|
||||||
|
from playsound import playsound
|
||||||
|
playsound('res/timesup.aac')
|
||||||
|
else:
|
||||||
|
sys.stdout.write('\a')
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
whatdid = ''
|
whatdid = ''
|
||||||
|
global GUI, QUIET
|
||||||
|
if "--no-gui" in sys.argv:
|
||||||
|
GUI = False
|
||||||
|
if "--noisy" in sys.argv:
|
||||||
|
QUIET = False
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
whatnext = pomodoro_prompt_plan(whatdid)
|
whatnext = pomodoro_prompt_plan(whatdid)
|
||||||
|
|
||||||
|
@ -119,8 +142,7 @@ def main():
|
||||||
print('Working on: ' + whatnext)
|
print('Working on: ' + whatnext)
|
||||||
countdown_to(end)
|
countdown_to(end)
|
||||||
if not QUIET:
|
if not QUIET:
|
||||||
from playsound import playsound
|
bing()
|
||||||
playsound('res/timesup.aac')
|
|
||||||
whatdid = pomodoro_prompt_report(whatnext)
|
whatdid = pomodoro_prompt_report(whatnext)
|
||||||
record_task(whatnext, whatdid, start)
|
record_task(whatnext, whatdid, start)
|
||||||
log_step('Completed pomodoro: ' + whatdid, start, True)
|
log_step('Completed pomodoro: ' + whatdid, start, True)
|
||||||
|
@ -132,7 +154,7 @@ def main():
|
||||||
end = datetime.now(pytz.utc) + timedelta(minutes=SHORT_MIN)
|
end = datetime.now(pytz.utc) + timedelta(minutes=SHORT_MIN)
|
||||||
countdown_to(end)
|
countdown_to(end)
|
||||||
if not QUIET:
|
if not QUIET:
|
||||||
playsound('res/timesup.aac')
|
bing()
|
||||||
continue
|
continue
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
if start is None:
|
if start is None:
|
||||||
|
|
Loading…
Reference in a new issue