diff --git a/CHANGELOG.md b/CHANGELOG.md index c3b2faed..7d655c71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ - refactor(notification): add `NotificationExtraInformation` with `text`, `piper_text`, and `orca_text` to replace the simple strings passed to `extra_information` field of the `Notification` object - refactor(audio): rename sound service to audio service - refactor(audio): drop `pyaudio` and use `simpleaudio` for playback +- feat(core): setting `DEBUG_MODE_MENU` environment variable to truthy values will show a representation of the menu in the logs whenever the current menu is changed ## Version 0.15.4 diff --git a/ubo_app/constants.py b/ubo_app/constants.py index a84f1373..e94b7472 100644 --- a/ubo_app/constants.py +++ b/ubo_app/constants.py @@ -20,6 +20,8 @@ SERVER_SOCKET_PATH = Path('/run/ubo').joinpath('system_manager.sock').as_posix() DISABLED_SERVICES = os.environ.get('UBO_DISABLED_SERVICES', '').split(',') +DEBUG_MODE_MENU = str_to_bool(os.environ.get('UBO_DEBUG_MENU', 'False')) == 1 + SERVICES_LOOP_GRACE_PERIOD = float( os.environ.get('UBO_SERVICES_LOOP_GRACE_PERIOD', 0.1), ) diff --git a/ubo_app/menu_app/menu_central.py b/ubo_app/menu_app/menu_central.py index f6eb00a0..58a62dd9 100644 --- a/ubo_app/menu_app/menu_central.py +++ b/ubo_app/menu_app/menu_central.py @@ -10,6 +10,8 @@ from ubo_gui.app import UboApp, cached_property from ubo_gui.menu import Item, MenuWidget, StackItem, StackMenuItem +from ubo_app.constants import DEBUG_MODE_MENU +from ubo_app.logging import logger from ubo_app.menu_app.menu_notification_handler import MenuNotificationHandler from ubo_app.store.core import ( ChooseMenuItemByIconEvent, @@ -108,6 +110,10 @@ def central(self: MenuAppCentral) -> Widget | None: self.menu_widget.bind(title=self.handle_title_change) self.menu_widget.bind(stack=set_path) + if DEBUG_MODE_MENU: + menu_representation = 'Menu:\n' + repr(self.menu_widget) + self.menu_widget.bind(stack=lambda *_: logger.info(menu_representation)) + subscribe_event( KeypadKeyPressEvent, self.handle_key_press_event,