diff --git a/bumblebee/modules/amixer.py b/bumblebee/modules/amixer.py new file mode 100644 index 0000000..e8991fb --- /dev/null +++ b/bumblebee/modules/amixer.py @@ -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" ] diff --git a/themes/icons/ascii.json b/themes/icons/ascii.json index de89921..c29c6d5 100644 --- a/themes/icons/ascii.json +++ b/themes/icons/ascii.json @@ -22,6 +22,10 @@ "muted": { "prefix": "audio(mute)" }, "unmuted": { "prefix": "audio" } }, + "amixer": { + "muted": { "prefix": "audio(mute)" }, + "unmuted": { "prefix": "audio" } + }, "pasource": { "muted": { "prefix": "mic(mute)" }, "unmuted": { "prefix": "mic" } diff --git a/themes/icons/awesome-fonts.json b/themes/icons/awesome-fonts.json index 69dd60f..a6c1c90 100644 --- a/themes/icons/awesome-fonts.json +++ b/themes/icons/awesome-fonts.json @@ -9,7 +9,6 @@ "cpu": { "prefix": "" }, "disk": { "prefix": "" }, "dnf": { "prefix": "" }, - "pacman": { "prefix": "" }, "brightness": { "prefix": "" }, "load": { "prefix": "" }, "layout": { "prefix": "" }, @@ -35,6 +34,10 @@ "muted": { "prefix": "" }, "unmuted": { "prefix": "" } }, + "amixer": { + "muted": { "prefix": "" }, + "unmuted": { "prefix": "" } + }, "pasource": { "muted": { "prefix": "" }, "unmuted": { "prefix": "" }