From 89fc9a7ac18219245c85a823729d2e298b3d251b Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Thu, 29 May 2025 10:07:38 -0700 Subject: [PATCH] add sound for mac and linux --- contact/message_handlers/rx_handler.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contact/message_handlers/rx_handler.py b/contact/message_handlers/rx_handler.py index bfba3d6..eaa2b14 100644 --- a/contact/message_handlers/rx_handler.py +++ b/contact/message_handlers/rx_handler.py @@ -1,4 +1,6 @@ import logging +import os +import platform import time from datetime import datetime from typing import Any, Dict @@ -22,6 +24,15 @@ import contact.ui.default_config as config from contact.utilities.singleton import ui_state, interface_state, app_state +def play_sound(): + if platform.system() == "Darwin": # macOS + os.system("afplay /System/Library/Sounds/Ping.aiff") + elif platform.system() == "Linux": + os.system("paplay /usr/share/sounds/freedesktop/stereo/complete.oga") + else: + print("\a") # fallback + + def on_receive(packet: Dict[str, Any], interface: Any) -> None: """ Handles an incoming packet from a Meshtastic interface. @@ -53,6 +64,8 @@ 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() + message_bytes = packet["decoded"]["payload"] message_string = message_bytes.decode("utf-8")