From 289b42b26a1b9a98bb6cc6146c984428477d2985 Mon Sep 17 00:00:00 2001 From: zetxx Date: Wed, 15 Mar 2017 23:12:55 +0200 Subject: [PATCH] fix: state, check regex result before use it --- bumblebee/modules/amixer.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bumblebee/modules/amixer.py b/bumblebee/modules/amixer.py index 4ed7271..fa08ec3 100644 --- a/bumblebee/modules/amixer.py +++ b/bumblebee/modules/amixer.py @@ -13,17 +13,19 @@ class Module(bumblebee.engine.Module): bumblebee.output.Widget(full_text=self.volume) ) self._level = "0" - self._muted = False + self._muted = True device = self.parameter("device", "Master,0") self._cmdString = "amixer get {}".format(device) def volume(self, widget): m = re.search(r'([\d]+)\%', self._level) - self._muted = False - if m == "0": - self._muted = True - - return "{}%".format(m.group(1)) + self._muted = True + if m: + if m.group(1) != "0": + self._muted = False + return "{}%".format(m.group(1)) + else: + return "0%" def update(self, widgets): self._level = bumblebee.util.execute(self._cmdString)