Add ability to use w/out GUI (via --no-gui)

And ring the console bell w/--noisy
This commit is contained in:
Chris (wolcen) Thompson 2024-11-18 21:39:33 -05:00
parent a9b6d3ca99
commit 5c111e96f1

View file

@ -15,6 +15,7 @@ SHORT_MIN = 5 # Minutes for a short break
LONG_MIN = 15 # Minutes for a long break (NOT YET IMPLEMENTED)
INTERRUPTED_MIN = 1 # Minimum minutes to ask to record an interrupted Pomodoro
QUIET = True
GUI = True
def pomodoro_prompt_plan(whatdid = ''):
""" 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?"
# 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.
whatnext = prompt_window.prompt(prompt=text, task=whatdid)
if GUI:
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.
if whatnext is None:
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
"""
text = "What'd you do?"
whatdid = prompt_window.prompt(prompt=text, task=whatnext)
if GUI:
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.
if whatdid is None:
whatdid = ''
@ -107,8 +116,22 @@ def prepare_file(utc_start, ext='csv', daily=False):
timelog_path += '.' + ext
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():
whatdid = ''
global GUI, QUIET
if "--no-gui" in sys.argv:
GUI = False
if "--noisy" in sys.argv:
QUIET = False
while True:
whatnext = pomodoro_prompt_plan(whatdid)
@ -119,8 +142,7 @@ def main():
print('Working on: ' + whatnext)
countdown_to(end)
if not QUIET:
from playsound import playsound
playsound('res/timesup.aac')
bing()
whatdid = pomodoro_prompt_report(whatnext)
record_task(whatnext, whatdid, start)
log_step('Completed pomodoro: ' + whatdid, start, True)
@ -132,7 +154,7 @@ def main():
end = datetime.now(pytz.utc) + timedelta(minutes=SHORT_MIN)
countdown_to(end)
if not QUIET:
playsound('res/timesup.aac')
bing()
continue
except KeyboardInterrupt:
if start is None: