Remove the battery widget if there is no battery

This commit is contained in:
Rodolphe Breard 2016-10-22 19:21:03 +02:00
parent 9ac8f2b2bb
commit 8f3e16f21e

View file

@ -51,6 +51,9 @@ class ConfigWrapper:
self._add_key(access_key, lazy.group[name].toscreen())
self._add_key(access_key, lazy.window.togroup(name), extra_mod='shift')
def _has_battery(self):
return len(glob('/sys/class/power_supply/BAT*')) > 0
def set_wallpaper(self):
images = glob(os.path.expanduser('~/pictures/wallpapers/enabled/*'))
if images:
@ -117,10 +120,7 @@ class ConfigWrapper:
)
def set_screens(self):
screens = [
Screen(
top=bar.Bar(
[
widgets = [
widget.GroupBox(),
widget.Prompt(),
widget.WindowName(),
@ -133,9 +133,12 @@ class ConfigWrapper:
widget.MemoryGraph(**self.graph_params('#CFCE44')),
widget.CPUGraph(**self.graph_params('#96AECF')),
widget.Clock(format=self.date_format),
],
30,
),
]
if not self._has_battery():
widgets = [w for w in widgets if not isinstance(w, widget.Battery)]
screens = [
Screen(
top=bar.Bar(widgets, 30)
),
]
return screens