diff options
-rw-r--r-- | pa.py | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -33,7 +33,12 @@ class SinkSource: def set_volume(self, vol): assert type(vol) == float or type(vol) == int + vol = max(0.0, min(1.0, vol)) vol = round(vol * _get_maxvol(self._i)) + self.set_raw_volume(vol) + + def set_raw_volume(self, vol): + assert type(vol) == float or type(vol) == int pacmd.pacmd("set-{}-volume".format(self._kind_of_thing), str(self.index()), str(vol)) @@ -68,6 +73,9 @@ class InputOutput: def linked_kind(self): return self._linked_kind + def properties(self): + return self._i + def name(self): try: name = self._i.ch["properties"].ch["media.name"].value @@ -102,15 +110,23 @@ class InputOutput: def set_volume(self, vol): assert type(vol) == float or type(vol) == int + vol = max(0.0, min(1.0, vol)) vol = round(vol * _get_maxvol(self._i)) - pacmd.pacmd("set-{}-volume".format(self._kind_of_thing), str(self.index()), str(vol)) + self.set_raw_volume(vol) + + def set_raw_volume(self, vol): + assert type(vol) == float or type(vol) == int + pacmd.pacmd("set-{}-volume".format(self._kind_of_thing), + str(self.index()), str(vol)) def set_muted(self, yes): - pacmd.pacmd("set-{}-mute".format(self._kind_of_thing), str(self.index()), "true" if yes else "false") + pacmd.pacmd("set-{}-mute".format(self._kind_of_thing), + str(self.index()), "true" if yes else "false") def move_to(self, idx): assert type(idx) == int - pacmd.pacmd("move-{}".format(self._kind_of_thing), str(self.index()), str(idx)) + pacmd.pacmd("move-{}".format(self._kind_of_thing), + str(self.index()), str(idx)) class SinkInput(InputOutput): def __init__(self, pitem): |