Merge pull request #53 from zetxx/master

new module: added volume level for amixer
This commit is contained in:
tobi-wan-kenobi 2017-03-16 07:50:23 +01:00 committed by GitHub
commit 1ec41051ac
3 changed files with 44 additions and 1 deletions

View file

@ -0,0 +1,36 @@
"""get volume level
"""
import re
import bumblebee.input
import bumblebee.output
import bumblebee.engine
class Module(bumblebee.engine.Module):
def __init__(self, engine, config):
super(Module, self).__init__(engine, config,
bumblebee.output.Widget(full_text=self.volume)
)
self._level = "0"
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 = 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)
def state(self, widget):
if self._muted:
return [ "warning", "muted" ]
return [ "unmuted" ]

View file

@ -22,6 +22,10 @@
"muted": { "prefix": "audio(mute)" }, "muted": { "prefix": "audio(mute)" },
"unmuted": { "prefix": "audio" } "unmuted": { "prefix": "audio" }
}, },
"amixer": {
"muted": { "prefix": "audio(mute)" },
"unmuted": { "prefix": "audio" }
},
"pasource": { "pasource": {
"muted": { "prefix": "mic(mute)" }, "muted": { "prefix": "mic(mute)" },
"unmuted": { "prefix": "mic" } "unmuted": { "prefix": "mic" }

View file

@ -9,7 +9,6 @@
"cpu": { "prefix": "" }, "cpu": { "prefix": "" },
"disk": { "prefix": "" }, "disk": { "prefix": "" },
"dnf": { "prefix": "" }, "dnf": { "prefix": "" },
"pacman": { "prefix": "" },
"brightness": { "prefix": "" }, "brightness": { "prefix": "" },
"load": { "prefix": "" }, "load": { "prefix": "" },
"layout": { "prefix": "" }, "layout": { "prefix": "" },
@ -35,6 +34,10 @@
"muted": { "prefix": "" }, "muted": { "prefix": "" },
"unmuted": { "prefix": "" } "unmuted": { "prefix": "" }
}, },
"amixer": {
"muted": { "prefix": "" },
"unmuted": { "prefix": "" }
},
"pasource": { "pasource": {
"muted": { "prefix": "" }, "muted": { "prefix": "" },
"unmuted": { "prefix": "" } "unmuted": { "prefix": "" }