a bit of refactoring, now batt and pacman plugins have more options
This commit is contained in:
parent
5e17aca8e2
commit
9cd7b68967
2 changed files with 22 additions and 23 deletions
|
@ -6,24 +6,24 @@ BATTERY_DIR = '/sys/class/power_supply/BAT0/'
|
|||
|
||||
class PluginThread(plugins.PluginThreadCommon):
|
||||
def __init__(self, config):
|
||||
super(PluginThread, self).__init__(config)
|
||||
defaults = {
|
||||
'problem': 15,
|
||||
'symbol_charging': '\u2191',
|
||||
'symbol_discharging': '\u2193'
|
||||
}
|
||||
super(PluginThread, self).__init__(config, defaults)
|
||||
|
||||
def main(self):
|
||||
with \
|
||||
open(BATTERY_DIR + 'capacity', 'r') as capacity, \
|
||||
open(BATTERY_DIR + 'status', 'r') as status:
|
||||
batt_stat = status.read().strip()
|
||||
batt_capacity = capacity.read().strip()
|
||||
if batt_stat != 'Discharging':
|
||||
batt_stat = '\u2191'
|
||||
if float(batt_capacity) < 15:
|
||||
self.status['urgent'] = True
|
||||
else:
|
||||
self.status['urgent'] = False
|
||||
else:
|
||||
batt_stat = '\u2193'
|
||||
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']
|
||||
|
||||
batt = 'BAT: ' + batt_capacity + '% ' + batt_stat
|
||||
|
||||
self.status['full_text'] = batt
|
||||
self.status['full_text'] = 'BAT: ' + capacity + '% ' + symbol
|
||||
|
|
|
@ -4,18 +4,17 @@ import subprocess
|
|||
|
||||
class PluginThread(plugins.PluginThreadCommon):
|
||||
def __init__(self, config):
|
||||
defaults = {'freq': 15}
|
||||
defaults = {
|
||||
'freq': 15,
|
||||
'problem': 10
|
||||
}
|
||||
super(PluginThread, self).__init__(config, defaults)
|
||||
self.format_status(0)
|
||||
|
||||
def format_status(self, count):
|
||||
self.status['full_text'] = 'UPD: ' + str(count)
|
||||
if count > 0:
|
||||
self.hide = False
|
||||
self.status['urgent'] = True
|
||||
else:
|
||||
self.hide = True
|
||||
self.status['urgent'] = False
|
||||
self.hide = count == 0
|
||||
self.status['urgent'] = count >= self.conf['problem']
|
||||
|
||||
def main(self):
|
||||
# TODO: this is an ugly hack, fix it with subprocess.Popen asap
|
||||
|
|
Loading…
Reference in a new issue