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):
|
class PluginThread(plugins.PluginThreadCommon):
|
||||||
def __init__(self, config):
|
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):
|
def main(self):
|
||||||
with \
|
with \
|
||||||
open(BATTERY_DIR + 'capacity', 'r') as capacity, \
|
open(BATTERY_DIR + 'capacity', 'r') as batt_capacity, \
|
||||||
open(BATTERY_DIR + 'status', 'r') as status:
|
open(BATTERY_DIR + 'status', 'r') as batt_status:
|
||||||
batt_stat = status.read().strip()
|
status = batt_status.read().strip()
|
||||||
batt_capacity = capacity.read().strip()
|
capacity = batt_capacity.read().strip()
|
||||||
if batt_stat != 'Discharging':
|
if status != 'Discharging':
|
||||||
batt_stat = '\u2191'
|
symbol = self.conf['symbol_charging']
|
||||||
if float(batt_capacity) < 15:
|
|
||||||
self.status['urgent'] = True
|
|
||||||
else:
|
|
||||||
self.status['urgent'] = False
|
self.status['urgent'] = False
|
||||||
else:
|
else:
|
||||||
batt_stat = '\u2193'
|
symbol = self.conf['symbol_discharging']
|
||||||
self.status['urgent'] = False
|
self.status['urgent'] = float(capacity) <= self.conf['problem']
|
||||||
|
|
||||||
batt = 'BAT: ' + batt_capacity + '% ' + batt_stat
|
self.status['full_text'] = 'BAT: ' + capacity + '% ' + symbol
|
||||||
|
|
||||||
self.status['full_text'] = batt
|
|
||||||
|
|
|
@ -4,18 +4,17 @@ import subprocess
|
||||||
|
|
||||||
class PluginThread(plugins.PluginThreadCommon):
|
class PluginThread(plugins.PluginThreadCommon):
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
defaults = {'freq': 15}
|
defaults = {
|
||||||
|
'freq': 15,
|
||||||
|
'problem': 10
|
||||||
|
}
|
||||||
super(PluginThread, self).__init__(config, defaults)
|
super(PluginThread, self).__init__(config, defaults)
|
||||||
self.format_status(0)
|
self.format_status(0)
|
||||||
|
|
||||||
def format_status(self, count):
|
def format_status(self, count):
|
||||||
self.status['full_text'] = 'UPD: ' + str(count)
|
self.status['full_text'] = 'UPD: ' + str(count)
|
||||||
if count > 0:
|
self.hide = count == 0
|
||||||
self.hide = False
|
self.status['urgent'] = count >= self.conf['problem']
|
||||||
self.status['urgent'] = True
|
|
||||||
else:
|
|
||||||
self.hide = True
|
|
||||||
self.status['urgent'] = False
|
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
# TODO: this is an ugly hack, fix it with subprocess.Popen asap
|
# TODO: this is an ugly hack, fix it with subprocess.Popen asap
|
||||||
|
|
Loading…
Reference in a new issue