[core] restructure to allow PIP packaging
OK - so I have to admit I *hate* the fact that PIP seems to require a subdirectory named like the library. But since the PIP package is something really nifty to have (thanks to @tony again!!!), I updated the codebase to hopefully conform with what PIP expects. Testruns so far look promising...
This commit is contained in:
parent
1d25be2059
commit
320827d577
146 changed files with 2509 additions and 2 deletions
51
bumblebee_status/modules/contrib/amixer.py
Normal file
51
bumblebee_status/modules/contrib/amixer.py
Normal file
|
@ -0,0 +1,51 @@
|
|||
"""get volume level
|
||||
|
||||
Parameters:
|
||||
* amixer.device: Device to use, defaults to "Master,0"
|
||||
|
||||
contributed by `zetxx <https://github.com/zetxx>`_ - many thanks!
|
||||
"""
|
||||
import re
|
||||
|
||||
import core.module
|
||||
import core.widget
|
||||
|
||||
import util.cli
|
||||
|
||||
|
||||
class Module(core.module.Module):
|
||||
def __init__(self, config, theme):
|
||||
super().__init__(config, theme, core.widget.Widget(self.volume))
|
||||
|
||||
self.__level = "n/a"
|
||||
self.__muted = True
|
||||
device = self.parameter("device", "Master,0")
|
||||
self._cmdString = "amixer get {}".format(device)
|
||||
|
||||
def volume(self, widget):
|
||||
if self.__level == "n/a":
|
||||
return self.__level
|
||||
m = re.search(r"([\d]+)\%", self.__level)
|
||||
self.__muted = True
|
||||
if m:
|
||||
if m.group(1) != "0" and "[on]" in self.__level:
|
||||
self.__muted = False
|
||||
return "{}%".format(m.group(1))
|
||||
else:
|
||||
return "0%"
|
||||
|
||||
def update(self):
|
||||
try:
|
||||
self.__level = util.cli.execute(
|
||||
"amixer get {}".format(self.parameter("device", "Master,0"))
|
||||
)
|
||||
except Exception as e:
|
||||
self.__level = "n/a"
|
||||
|
||||
def state(self, widget):
|
||||
if self.__muted:
|
||||
return ["warning", "muted"]
|
||||
return ["unmuted"]
|
||||
|
||||
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
Loading…
Add table
Add a link
Reference in a new issue