blob: b89d00d7616a675ddd23fd60e934a9c70877ed73 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import plugins
BATTERY_DIR = '/sys/class/power_supply/BAT0/'
BATT_DEFAULTS = {
'problem': 15,
'symbol_charging': '\u2191',
'symbol_discharging': '\u2193'
}
class PluginThread(plugins.PluginThreadCommon):
def __init__(self, config):
super(PluginThread, self).__init__(config, BATT_DEFAULTS)
def main(self):
with \
open(BATTERY_DIR + 'capacity', 'r') as batt_capacity, \
open(BATTERY_DIR + 'status', 'r') as batt_status:
status = batt_status.read().strip()
capacity = batt_capacity.read().strip()
if status != 'Discharging':
symbol = self.conf['symbol_charging']
self.status['urgent'] = False
else:
symbol = self.conf['symbol_discharging']
self.status['urgent'] = float(capacity) <= self.conf['problem']
self.status['full_text'] = 'BAT: ' + capacity + '% ' + symbol
|