forked from iarv/contact
Compare commits
6 Commits
1.3.10
...
notificati
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ade8343104 | ||
|
|
d6427f3fca | ||
|
|
fba32bb10c | ||
|
|
1e0432642c | ||
|
|
89fc9a7ac1 | ||
|
|
71f37065bf |
@@ -1,4 +1,8 @@
|
||||
import logging
|
||||
import os
|
||||
import platform
|
||||
import shutil
|
||||
import subprocess
|
||||
import time
|
||||
from datetime import datetime
|
||||
from typing import Any, Dict
|
||||
@@ -22,6 +26,41 @@ import contact.ui.default_config as config
|
||||
from contact.utilities.singleton import ui_state, interface_state, app_state
|
||||
|
||||
|
||||
def play_sound():
|
||||
try:
|
||||
system = platform.system()
|
||||
|
||||
if system == "Darwin": # macOS
|
||||
sound_path = "/System/Library/Sounds/Ping.aiff"
|
||||
if os.path.exists(sound_path):
|
||||
subprocess.run(["afplay", sound_path], check=True)
|
||||
return
|
||||
else:
|
||||
print(f"[WARN] macOS sound file not found: {sound_path}")
|
||||
|
||||
elif system == "Linux":
|
||||
sound_path = "/usr/share/sounds/freedesktop/stereo/complete.oga"
|
||||
if os.path.exists(sound_path):
|
||||
if shutil.which("paplay"):
|
||||
subprocess.run(["paplay", sound_path], check=True)
|
||||
return
|
||||
elif shutil.which("aplay"):
|
||||
subprocess.run(["aplay", sound_path], check=True)
|
||||
return
|
||||
else:
|
||||
print("[WARN] No sound player found (paplay/aplay)")
|
||||
else:
|
||||
print(f"[WARN] Linux sound file not found: {sound_path}")
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"[ERROR] Sound playback failed: {e}")
|
||||
except Exception as e:
|
||||
print(f"[ERROR] Unexpected error: {e}")
|
||||
|
||||
# Final fallback: terminal beep
|
||||
print("\a")
|
||||
|
||||
|
||||
def on_receive(packet: Dict[str, Any], interface: Any) -> None:
|
||||
"""
|
||||
Handles an incoming packet from a Meshtastic interface.
|
||||
@@ -53,6 +92,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")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "contact"
|
||||
version = "1.3.9"
|
||||
version = "1.3.10"
|
||||
description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores."
|
||||
authors = [
|
||||
{name = "Ben Lipsey",email = "ben@pdxlocations.com"}
|
||||
|
||||
Reference in New Issue
Block a user