Sunday, January 14, 2018

mute an application

import os
import re
import sys

sindex = os.popen("pacmd list-sink-inputs")

sindexl = sindex.read().split("\n")
loopstart = False
comm = sys.argv[1]
appname = sys.argv[2]
mindexx = 0
for i  in sindexl:
    # print [i]
    if re.search("index: ", i):
        mindex = re.sub("index:","", i).strip()
    if re.search("application.name",i):
        if re.search(appname, i.lower()):
            mindexx =mindex
            break
print mindexx
if comm == "mute":
    os.system("pacmd set-sink-input-mute "+mindexx+" 1")
    print "muted"
elif comm =="unmute":
    os.system("pacmd set-sink-input-mute "+mindexx+" 0")
    print "muted"





1- usage

$ python muteapp.py mute vlc
$ python muteapp.py unmute vlc

No comments:

Post a Comment