def is_muted_old(self): """This uses `pacmd dump`""" self._update_sink_to_use() pacmd_dump = sh.pacmd('dump').strip().splitlines() for l in pacmd_dump: _title_re = 'set-sink-mute {0} (.*)'.format(self._sink_name) match = re.search(_title_re, l) if match is not None: return match.group(1) == "yes"
def main(): MAX = 0xFFFF ICON_VOL_HIGH = '\uf028' ICON_VOL_MED = '\uf027' ICON_VOL_LOW = '\uf026' # 'pacmd list-sinks | grep "* index" | awk \'{print $3}\'' dump = str(sh.pacmd('dump').wait()) for line in dump.split('\n'): if line.startswith('set-sink-volume alsa'): vol = line.split(' ')[-1] vol = int(vol, 16) / MAX vol = vol * 100 icon = ICON_VOL_LOW if vol >= 25: icon = ICON_VOL_MED if vol >= 50: icon = ICON_VOL_HIGH print('{icon} {00:.0f}%'.format(round(vol, 0), icon=icon)) break
#!/usr/bin/python from sh import ( pacmd, pactl, ) if "teesink" in pacmd("list-sinks"): print "Already have a teesink." else: pactl("load-module", "module-combine-sink", "sink_name=teesink", "slaves=null,alsa_output.pci-0000_00_1b.0.analog-stereo")