[modules/battery] Migrate constructor
This commit is contained in:
parent
c2b0c8e754
commit
9b96c142d5
1 changed files with 13 additions and 15 deletions
|
@ -13,30 +13,28 @@ Parameters:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import glob
|
import glob
|
||||||
|
import power
|
||||||
|
|
||||||
import bumblebee.input
|
import core.module
|
||||||
import bumblebee.output
|
import core.widget
|
||||||
import bumblebee.engine
|
import core.input
|
||||||
import bumblebee.util
|
|
||||||
|
|
||||||
try:
|
import util.format
|
||||||
import power
|
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
class Module(bumblebee.engine.Module):
|
class Module(core.module.Module):
|
||||||
def __init__(self, engine, config):
|
def __init__(self, config=None):
|
||||||
widgets = []
|
widgets = []
|
||||||
super(Module, self).__init__(engine, config, widgets)
|
super().__init__(config, widgets)
|
||||||
self._batteries = self.parameter('device', 'auto').split(',')
|
|
||||||
|
self._batteries = util.format.aslist(self.parameter('device', 'auto'))
|
||||||
if self._batteries[0] == 'auto':
|
if self._batteries[0] == 'auto':
|
||||||
self._batteries = glob.glob('/sys/class/power_supply/BAT*')
|
self._batteries = glob.glob('/sys/class/power_supply/BAT*')
|
||||||
else:
|
else:
|
||||||
self._batteries = ['/sys/class/power_supply/{}'.format(b) for b in self._batteries]
|
self._batteries = ['/sys/class/power_supply/{}'.format(b) for b in self._batteries]
|
||||||
if len(self._batteries) == 0:
|
if len(self._batteries) == 0:
|
||||||
self._batteries = ['/sys/class/power_supply/BAT0']
|
raise Exceptions('no batteries configured/found')
|
||||||
self.update(widgets)
|
self.update()
|
||||||
engine.input.register_callback(self, button=bumblebee.input.LEFT_MOUSE,
|
core.input.register(self, button=core.input.LEFT_MOUSE,
|
||||||
cmd='gnome-power-statistics')
|
cmd='gnome-power-statistics')
|
||||||
|
|
||||||
def update(self, widgets):
|
def update(self, widgets):
|
||||||
|
|
Loading…
Reference in a new issue