From 9a8de718baee01505d3c7e0ae213b3918774ec50 Mon Sep 17 00:00:00 2001 From: Till Immer Date: Mon, 6 Jul 2026 17:03:35 +0000 Subject: [PATCH] =?UTF-8?q?audio=5Fmanager.py=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- audio_manager.py | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 audio_manager.py diff --git a/audio_manager.py b/audio_manager.py new file mode 100644 index 0000000..74441b3 --- /dev/null +++ b/audio_manager.py @@ -0,0 +1,39 @@ +import subprocess +import logging + +log = logging.getLogger("AudioManager") + + +class AudioManager: + def __init__(self): + self.current_sink = None + + # ------------------- + # SPOTIFY CONTROL + # ------------------- + def spotify_play(self): + subprocess.run(["playerctl", "-p", "spotify", "play"]) + + def spotify_pause(self): + subprocess.run(["playerctl", "-p", "spotify", "pause"]) + + def spotify_next(self): + subprocess.run(["playerctl", "-p", "spotify", "next"]) + + # ------------------- + # VOLUME CONTROL + # ------------------- + def set_volume(self, vol: int): + subprocess.run(["pactl", "set-sink-volume", "@DEFAULT_SINK@", f"{vol}%"]) + + # ------------------- + # BLUETOOTH ROUTING + # ------------------- + def set_sink(self, sink_name: str): + subprocess.run(["pactl", "set-default-sink", sink_name]) + + # ------------------- + # STATUS + # ------------------- + def status(self): + return subprocess.getoutput("playerctl status") \ No newline at end of file