Skip to content

Commit

Permalink
feat(core): setting DEBUG_MODE_MENU environment variable to truthy …
Browse files Browse the repository at this point in the history
…values will show a representation of the menu in the logs whenever the current menu is changed
  • Loading branch information
sassanh committed Jul 29, 2024
1 parent 842ba28 commit 81ef25f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions ubo_app/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)
Expand Down
6 changes: 6 additions & 0 deletions ubo_app/menu_app/menu_central.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 81ef25f

Please sign in to comment.