From 20bc4b3fa6ef319b766339657095772804da3cb2 Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 10 Sep 2022 09:01:21 +0200 Subject: [PATCH] [modules/pulsectl] add parameter to set an upper limit --- bumblebee_status/modules/core/pulsectl.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bumblebee_status/modules/core/pulsectl.py b/bumblebee_status/modules/core/pulsectl.py index 8d36646..f8fa6a2 100644 --- a/bumblebee_status/modules/core/pulsectl.py +++ b/bumblebee_status/modules/core/pulsectl.py @@ -22,6 +22,7 @@ class Module(core.module.Module): self.__change = util.format.asint( self.parameter("percent_change", "2%").strip("%"), 0, 100 ) + self.__limit = util.format.asint(self.parameter("limit", "0%").strip("%"), 0) events = [ { @@ -62,6 +63,8 @@ class Module(core.module.Module): dev = self.get_device(pulse) vol = dev.volume vol.value_flat += amount + if vol.value_flat > self.__limit/100: + vol.value_flat = self.__limit/100 pulse.volume_set(dev, vol) def increase_volume(self, _):