2016-10-30 18:10:25 +01:00
|
|
|
import datetime
|
|
|
|
import bumblebee.module
|
|
|
|
|
|
|
|
class Module(bumblebee.module.Module):
|
|
|
|
def __init__(self, theme, args):
|
|
|
|
super(Module, self).__init__(theme, args)
|
|
|
|
self._battery = "BAT0" if not args else args[0]
|
|
|
|
self._capacity = 0
|
|
|
|
self._status = "Unknown"
|
|
|
|
|
|
|
|
def data(self):
|
|
|
|
with open("/sys/class/power_supply/%s/capacity" % self._battery) as f:
|
|
|
|
self._capacity = int(f.read())
|
|
|
|
|
|
|
|
return "%02d%%" % self._capacity
|
|
|
|
|
2016-10-31 07:34:43 +01:00
|
|
|
def state(self):
|
|
|
|
with open("/sys/class/power_supply/%s/status" % self._battery) as f:
|
|
|
|
self._status = f.read().strip()
|
|
|
|
if self._status == "Discharging":
|
|
|
|
return "discharging"
|
|
|
|
else:
|
|
|
|
return "charging"
|
2016-10-30 18:10:25 +01:00
|
|
|
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|