Extracts notification logic into a reusable utility

Moves desktop notification functionality to a separate module for better code reuse and maintainability. Updates the main application to use the new utility.
This commit is contained in:
2025-03-24 14:26:24 +01:00
parent 36bad26e91
commit 92d66fb46c
2 changed files with 36 additions and 8 deletions

22
notify.py Normal file
View File

@@ -0,0 +1,22 @@
import subprocess
def notify(title: str, message: str) -> None:
"""
Sends a desktop notification using the `notify-send` command.
Args:
title (str): The title of the notification.
message (str): The message content of the notification.
Raises:
subprocess.CalledProcessError: If the `notify-send` command fails.
Note:
This function requires the `notify-send` command to be available on the system.
It is typically available on Linux systems with a notification daemon running.
"""
try:
subprocess.run(["notify-send", "-a", "Voice to Text", "-i", "audio-input-microphone", title, message], check=True)
except subprocess.CalledProcessError as e:
print("Fehler beim Benachrichtigen mit 'notify-send'.")
print(e)