You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
#!/usr/bin/env python
|
|
import time
|
|
import serial
|
|
import os
|
|
import subprocess
|
|
|
|
ser = serial.Serial(port='/dev/ttyUSB0',baudrate = 9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=1)
|
|
last = "0"
|
|
cmd1="pactl list sink-inputs | grep -B 18 -i 'VLC media player (LibVLC 3.0.16)' | grep -i 'Entrada de destino' | awk '{print $4}'"
|
|
vlcID = subprocess.Popen(cmd1,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,universal_newlines=True); vlcOut,vlcErr=vlcID.communicate(); rc=vlcID.wait()
|
|
vlcOut = vlcOut[1:]
|
|
vlcOut = vlcOut.replace('\n', '')
|
|
|
|
print("ID del VLC para usar con pactl: " + vlcOut)
|
|
|
|
while 1:
|
|
x = ser.readline()
|
|
x = x.decode()
|
|
x = x.replace('\n', '')
|
|
x = x.replace('\r', '')
|
|
|
|
if ( x != last ):
|
|
vlcID = subprocess.Popen(cmd1,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE,universal_newlines=True); vlcOut,vlcErr=vlcID.communicate(); rc=vlcID.wait()
|
|
vlcOut = vlcOut[1:]
|
|
vlcOut = vlcOut.replace('\n', '')
|
|
#cmd2 = "amixer set Master " + str(x) + "%"
|
|
#cmd2 = "amixer set Headphone " + str(x) + "%"
|
|
cmd2 = "pactl set-sink-input-volume " + vlcOut + " " + str(x) + "%"
|
|
print(cmd2)
|
|
os.system(cmd2)
|
|
last = x
|