feat: added volume level for amixer

This commit is contained in:
zetxx 2017-03-15 22:55:05 +02:00
parent 8767bcf4ec
commit 69e4780182
3 changed files with 42 additions and 1 deletions

View file

@ -0,0 +1,34 @@
"""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 = False
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))
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": "" }