From 59edfab451d169ee65e27aeca610d6ece485ac62 Mon Sep 17 00:00:00 2001 From: pdxlocations <117498748+pdxlocations@users.noreply.github.com> Date: Mon, 9 Jun 2025 22:15:53 -0700 Subject: [PATCH] add notif sound prefs (#190) --- contact/message_handlers/rx_handler.py | 4 +++- contact/ui/default_config.py | 6 ++++-- contact/ui/user_config.py | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/contact/message_handlers/rx_handler.py b/contact/message_handlers/rx_handler.py index 8e1bbbc..fa4d166 100644 --- a/contact/message_handlers/rx_handler.py +++ b/contact/message_handlers/rx_handler.py @@ -92,7 +92,9 @@ def on_receive(packet: Dict[str, Any], interface: Any) -> None: maybe_store_nodeinfo_in_db(packet) elif packet["decoded"]["portnum"] == "TEXT_MESSAGE_APP": - play_sound() + + if config.notification_sound == "True": + play_sound() message_bytes = packet["decoded"]["payload"] message_string = message_bytes.decode("utf-8") diff --git a/contact/ui/default_config.py b/contact/ui/default_config.py index fbce7e8..f0034b5 100644 --- a/contact/ui/default_config.py +++ b/contact/ui/default_config.py @@ -134,6 +134,7 @@ def initialize_config() -> Dict[str, object]: "message_prefix": ">>", "sent_message_prefix": ">> Sent", "notification_symbol": "*", + "notification_sound": "True", "ack_implicit_str": "[◌]", "ack_str": "[✓]", "nak_str": "[x]", @@ -174,7 +175,7 @@ def assign_config_variables(loaded_config: Dict[str, object]) -> None: global notification_symbol, ack_implicit_str, ack_str, nak_str, ack_unknown_str global node_list_16ths, channel_list_16ths global theme, COLOR_CONFIG - global node_sort + global node_sort, notification_sound channel_list_16ths = loaded_config["channel_list_16ths"] node_list_16ths = loaded_config["node_list_16ths"] @@ -183,10 +184,12 @@ def assign_config_variables(loaded_config: Dict[str, object]) -> None: message_prefix = loaded_config["message_prefix"] sent_message_prefix = loaded_config["sent_message_prefix"] notification_symbol = loaded_config["notification_symbol"] + notification_sound = loaded_config["notification_sound"] ack_implicit_str = loaded_config["ack_implicit_str"] ack_str = loaded_config["ack_str"] nak_str = loaded_config["nak_str"] ack_unknown_str = loaded_config["ack_unknown_str"] + node_sort = loaded_config["node_sort"] theme = loaded_config["theme"] if theme == "dark": COLOR_CONFIG = loaded_config["COLOR_CONFIG_DARK"] @@ -194,7 +197,6 @@ def assign_config_variables(loaded_config: Dict[str, object]) -> None: COLOR_CONFIG = loaded_config["COLOR_CONFIG_LIGHT"] elif theme == "green": COLOR_CONFIG = loaded_config["COLOR_CONFIG_GREEN"] - node_sort = loaded_config["node_sort"] # Call the function when the script is imported diff --git a/contact/ui/user_config.py b/contact/ui/user_config.py index 106bba6..cb67072 100644 --- a/contact/ui/user_config.py +++ b/contact/ui/user_config.py @@ -55,10 +55,15 @@ def edit_value(key: str, current_value: str) -> str: # Load theme names dynamically from the JSON theme_options = [k.split("_", 2)[2].lower() for k in loaded_config.keys() if k.startswith("COLOR_CONFIG")] return get_list_input("Select Theme", current_value, theme_options) + elif key == "node_sort": sort_options = ["lastHeard", "name", "hops"] return get_list_input("Sort By", current_value, sort_options) + elif key == "notification_sound": + sound_options = ["True", "False"] + return get_list_input("Notification Sound", current_value, sound_options) + # Standard Input Mode (Scrollable) edit_win.addstr(7, 2, "New Value: ", get_color("settings_default")) curses.curs_set(1)