codigo python inicial
parent
27443e207b
commit
8aebd0b0a9
@ -0,0 +1,31 @@
|
|||||||
|
#!/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
|
Loading…
Reference in New Issue