diff --git a/plugins/__init__.py b/plugins/__init__.py index 3f61ec8..016b462 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -19,7 +19,7 @@ class PluginThreadCommon: def format_status(self, status, urgent=False): if 'title' in self.conf: - full_text = self.conf['title'] + ': ' + status + full_text = '{}: {}'.format(self.conf['title'], status) else: full_text = status self.status.update({'full_text': full_text, 'urgent': urgent}) diff --git a/plugins/batt.py b/plugins/batt.py index b932ce5..4ec4595 100644 --- a/plugins/batt.py +++ b/plugins/batt.py @@ -1,7 +1,6 @@ import plugins -BATTERY_DIR = '/sys/class/power_supply/BAT0/' BATT_DEFAULTS = { 'problem': 15, 'symbol_charging': '\u2191', @@ -15,10 +14,10 @@ class PluginThread(plugins.PluginThreadCommon): def main(self): with \ - open(BATTERY_DIR + 'capacity', 'r') as batt_capacity, \ - open(BATTERY_DIR + 'status', 'r') as batt_status: - capacity = batt_capacity.readline().strip() - status_value = batt_status.readline().strip() + open('/sys/class/power_supply/BAT0/capacity', 'r') as bcap, \ + open('/sys/class/power_supply/BAT0/status', 'r') as bstat: + capacity = bcap.readline().strip() + status_value = bstat.readline().strip() if status_value != 'Discharging': symbol = self.conf['symbol_charging'] @@ -27,4 +26,5 @@ class PluginThread(plugins.PluginThreadCommon): symbol = self.conf['symbol_discharging'] urgent = float(capacity) <= self.conf['problem'] - self.format_status(capacity + '% ' + symbol, urgent=urgent) + status = '{}% {}'.format(capacity, symbol) + self.format_status(status, urgent) diff --git a/plugins/date.py b/plugins/date.py index 9e2a292..08e8601 100644 --- a/plugins/date.py +++ b/plugins/date.py @@ -14,5 +14,7 @@ class PluginThread(plugins.PluginThreadCommon): self.timezone = pytz.timezone(self.conf['tz']) def main(self): - now = datetime.datetime.now(tz=self.timezone) - self.format_status(now.strftime(self.conf['format'])) + now = datetime.datetime\ + .now(tz=self.timezone)\ + .strftime(self.conf['format']) + self.format_status(now) diff --git a/plugins/disk.py b/plugins/disk.py index 6085795..7797447 100644 --- a/plugins/disk.py +++ b/plugins/disk.py @@ -19,5 +19,6 @@ class PluginThread(plugins.PluginThreadCommon): else: self.hide = True self.status['urgent'] = False + status = '{:.2f}G'.format(du_stat.free / 2**30) self.format_status(status) diff --git a/plugins/filecat.py b/plugins/filecat.py index 5f404c9..0b6d82a 100644 --- a/plugins/filecat.py +++ b/plugins/filecat.py @@ -11,7 +11,6 @@ class PluginThread(plugins.PluginThreadCommon): def __init__(self, config): super(PluginThread, self).__init__(config, FILECAT_DEFAULTS) self.hide = False - self.format_status(self.conf['title'], False) def main(self): try: @@ -21,4 +20,5 @@ class PluginThread(plugins.PluginThreadCommon): except FileNotFoundError: contents = self.conf['nofile'] urgent = True + self.format_status(contents, urgent) diff --git a/plugins/fortune.py b/plugins/fortune.py index 0f35354..40b3f1d 100644 --- a/plugins/fortune.py +++ b/plugins/fortune.py @@ -25,6 +25,7 @@ class PluginThread(plugins.PluginThreadCommon): except requests.exceptions.ConnectionError: fortune = 'N/A (offline)' self.retry = True + self.format_status(fortune) def run(self): diff --git a/plugins/load.py b/plugins/load.py index d68441f..13c948f 100644 --- a/plugins/load.py +++ b/plugins/load.py @@ -18,4 +18,5 @@ class PluginThread(plugins.PluginThreadCommon): self.hide = True urgent = False status = '{:.2f} {:.2f} {:.2f}'.format(*loads) - self.format_status(status, urgent=urgent) + + self.format_status(status, urgent) diff --git a/plugins/mem.py b/plugins/mem.py index 2eeaad5..1463377 100644 --- a/plugins/mem.py +++ b/plugins/mem.py @@ -17,5 +17,6 @@ class PluginThread(plugins.PluginThreadCommon): else: self.hide = True urgent = False - mem_available = round(mem_stat.available / 2**30, 2) - self.format_status('{:.2f}G'.format(mem_available), urgent) + + status = '{:.2f}G'.format(mem_stat.available / 2**30) + self.format_status(status, urgent) diff --git a/plugins/pacman.py b/plugins/pacman.py index 625314b..2b4551f 100644 --- a/plugins/pacman.py +++ b/plugins/pacman.py @@ -24,6 +24,6 @@ class PluginThread(plugins.PluginThreadCommon): self.hide = False else: self.hide = True - self.format_status( - str(packages), urgent=packages >= self.conf['problem'] - ) + + urgent = packages >= self.conf['problem'] + self.format_status(packages, urgent) diff --git a/plugins/ping.py b/plugins/ping.py index e919dea..983a234 100644 --- a/plugins/ping.py +++ b/plugins/ping.py @@ -23,4 +23,4 @@ class PluginThread(plugins.PluginThreadCommon): if fping.returncode == 0: self.format_status('up') else: - self.format_status('down', urgent=True) + self.format_status('down', True)