nixos-configuration/pkgs/mute-indicator/pulseaudio_mute_indicator/service.py
Jakob Lechner 0b97afa7ce
Revert "Split UMC202HD inputs into mono channels"
This reverts commit d2b01eaf44.

pipewire-media-session is no longer supported upstream and has been removed
2023-05-23 16:40:50 +00:00

28 lines
1.1 KiB
Python

import pulsectl
import serial
def run():
with pulsectl.Pulse("event-printer") as pulse:
def print_events(ev):
with pulsectl.Pulse("event-source-info") as pulse2:
source = pulse2.source_info(ev.index)
if source.name in [
"alsa_input.usb-BEHRINGER_UMC202HD_192k-00.analog-stereo",
"alsa_input.usb-BEHRINGER_UMC202HD_192k-00.analog-stereo-input",
]:
muted = bool(source.mute)
with serial.Serial(port="/dev/mute-indicator", baudrate=115200) as ser:
if muted:
ser.write("L0:32,0,0\n".encode())
ser.write("L1:32,0,0\n".encode())
ser.write("S\n".encode())
else:
ser.write("L0:0,32,0\n".encode())
ser.write("L1:0,32,0\n".encode())
ser.write("S\n".encode())
pulse.event_mask_set("source")
pulse.event_callback_set(print_events)
pulse.event_listen(timeout=0)