aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2020-06-06 13:40:56 +0200
committerTom Smeding <tom.smeding@gmail.com>2020-06-06 13:40:56 +0200
commit6f5974d2e670b854e6d75febeb489178cbcd4c15 (patch)
tree71b076500e6a0e60a2af2028e58dee70df7abaca
parent41d7e8bf244bdff178ddd3654b96a6228ec20106 (diff)
.set_raw_volume() and .properties() on pa
-rw-r--r--pa.py22
1 files changed, 19 insertions, 3 deletions
diff --git a/pa.py b/pa.py
index e09565e..640a143 100644
--- a/pa.py
+++ b/pa.py
@@ -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):