diff --git a/flomo/cli.py b/flomo/cli.py index 6d7bf38..ee01fe2 100644 --- a/flomo/cli.py +++ b/flomo/cli.py @@ -64,6 +64,10 @@ def start(tag: str, name: str): """ try: tag = tag.lower() + if tag not in conf.Config().get_config(conf.TAG_COLORS): + conf.Config().set_config( + conf.TAG_COLORS, f"{tag} aquamarine3", nested_value=True + ) db = tracker.Tracker() db.create_table() session_id = db.create_session(tag, name, datetime.datetime.now()) diff --git a/flomo/ui.py b/flomo/ui.py index d45f587..8761c0e 100644 --- a/flomo/ui.py +++ b/flomo/ui.py @@ -1,4 +1,3 @@ -import datetime import threading import time @@ -8,7 +7,6 @@ from rich.panel import Panel from rich.text import Text -import flomo.config as config import flomo.helpers as helpers import flomo.tracker as tracker @@ -31,7 +29,6 @@ def __init__( f"bold {self.tag_color}" if self.status == 0 else "bold red" ) - self.terminal = blessed.Terminal() def generate_panel(self): @@ -66,7 +63,7 @@ def show_live_panel(self): def get_input(self): with self.terminal.cbreak(), self.terminal.hidden_cursor(): - return self.terminal.inkey().lower() + return self.terminal.inkey(timeout=0.1).lower() def main(tag: str, name: str, session_id: str): @@ -97,22 +94,18 @@ def main(tag: str, name: str, session_id: str): del flowing_ui chilling_ui = UI(1, tag, name, int(chilling_time)) - chilling_ui.show_live_panel() - # TODO: Fix skipping break issue - # chilling_panel_thread = threading.Thread( - # target=chilling_ui.show_live_panel, daemon=True) - # chilling_panel_thread.start() - - # while True: - # if chilling_ui.chilling_time == 1: - # break - # helpers.message_log(str(chilling_ui.chilling_time)) - # inp = chilling_ui.get_input() - # if inp == "q": - # break + + chilling_panel_thread = threading.Thread( + target=chilling_ui.show_live_panel, daemon=True) + chilling_panel_thread.start() + + while chilling_ui.chilling_time > 1: # type: ignore + inp = chilling_ui.get_input() + if inp == "q": + break chilling_ui.close_live_panel = True - # chilling_panel_thread.join() + chilling_panel_thread.join() del chilling_ui except KeyboardInterrupt: @@ -124,7 +117,7 @@ def main(tag: str, name: str, session_id: str): flowing_panel_thread.join() if "play_sound_thread" in locals() and play_sound_thread.is_alive(): play_sound_thread.join() - # if 'chilling_panel_thread' in locals() and chilling_panel_thread.is_alive(): - # chilling_panel_thread.join() + if 'chilling_panel_thread' in locals() and chilling_panel_thread.is_alive(): + chilling_panel_thread.join() finally: tracker.end_session(session_id)