[modules/pulsectl] add parameter to set an upper limit
This commit is contained in:
parent
ca6bf2e189
commit
20bc4b3fa6
1 changed files with 3 additions and 0 deletions
|
@ -22,6 +22,7 @@ class Module(core.module.Module):
|
||||||
self.__change = util.format.asint(
|
self.__change = util.format.asint(
|
||||||
self.parameter("percent_change", "2%").strip("%"), 0, 100
|
self.parameter("percent_change", "2%").strip("%"), 0, 100
|
||||||
)
|
)
|
||||||
|
self.__limit = util.format.asint(self.parameter("limit", "0%").strip("%"), 0)
|
||||||
|
|
||||||
events = [
|
events = [
|
||||||
{
|
{
|
||||||
|
@ -62,6 +63,8 @@ class Module(core.module.Module):
|
||||||
dev = self.get_device(pulse)
|
dev = self.get_device(pulse)
|
||||||
vol = dev.volume
|
vol = dev.volume
|
||||||
vol.value_flat += amount
|
vol.value_flat += amount
|
||||||
|
if vol.value_flat > self.__limit/100:
|
||||||
|
vol.value_flat = self.__limit/100
|
||||||
pulse.volume_set(dev, vol)
|
pulse.volume_set(dev, vol)
|
||||||
|
|
||||||
def increase_volume(self, _):
|
def increase_volume(self, _):
|
||||||
|
|
Loading…
Reference in a new issue