2016-11-28 13:48:11 +02:00
|
|
|
import plugins
|
2016-10-22 19:27:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
BATTERY_DIR = '/sys/class/power_supply/BAT0/'
|
|
|
|
|
|
|
|
|
2016-11-28 13:48:11 +02:00
|
|
|
class PluginThread(plugins.PluginThreadCommon):
|
2017-12-16 01:55:28 +02:00
|
|
|
def __init__(self, config):
|
|
|
|
super(PluginThread, self).__init__(config)
|
2016-10-22 19:27:28 +03:00
|
|
|
|
|
|
|
def main(self):
|
2017-12-16 01:55:28 +02:00
|
|
|
with \
|
|
|
|
open(BATTERY_DIR + 'capacity', 'r') as capacity, \
|
2016-10-22 19:27:28 +03:00
|
|
|
open(BATTERY_DIR + 'status', 'r') as status:
|
|
|
|
batt_stat = status.read().strip()
|
|
|
|
batt_capacity = capacity.read().strip()
|
|
|
|
if batt_stat != 'Discharging':
|
|
|
|
batt_stat = '\u2191'
|
2016-10-25 19:48:40 +03:00
|
|
|
if float(batt_capacity) < 15:
|
|
|
|
self.status['urgent'] = True
|
2016-10-31 15:35:38 +02:00
|
|
|
else:
|
|
|
|
self.status['urgent'] = False
|
2016-10-22 19:27:28 +03:00
|
|
|
else:
|
|
|
|
batt_stat = '\u2193'
|
2016-10-31 15:35:38 +02:00
|
|
|
self.status['urgent'] = False
|
2016-10-25 19:48:40 +03:00
|
|
|
|
2016-10-22 19:27:28 +03:00
|
|
|
batt = 'BAT: ' + batt_capacity + '% ' + batt_stat
|
|
|
|
|
|
|
|
self.status['full_text'] = batt
|