diff --git a/bumblebee/output.py b/bumblebee/output.py index 1f494ad..cfdc88b 100644 --- a/bumblebee/output.py +++ b/bumblebee/output.py @@ -1,8 +1,7 @@ import os -import shlex import inspect import threading -import subprocess +import bumblebee.util def output(args): import bumblebee.outputs.i3 @@ -57,8 +56,7 @@ class Command(object): cmd(self._event, self._widget) else: c = cmd.format(*args, **kwargs) - DEVNULL = open(os.devnull, 'wb') - subprocess.Popen(shlex.split(c), stdout=DEVNULL, stderr=DEVNULL) + bumblebee.util.execute(c, False) class Output(object): def __init__(self, config): @@ -103,14 +101,14 @@ class Output(object): def wait(self): self._wait.wait(self._config.parameter("interval", 1)) - def start(self): - pass - def draw(self, widgets, theme): if not type(widgets) is list: widgets = [ widgets ] self._draw(widgets, theme) + def start(self): + pass + def _draw(self, widgets, theme): pass diff --git a/bumblebee/outputs/i3.py b/bumblebee/outputs/i3.py index c0800dd..e287c6c 100644 --- a/bumblebee/outputs/i3.py +++ b/bumblebee/outputs/i3.py @@ -51,10 +51,6 @@ class Output(bumblebee.output.Output): "separator_block_width": 0, }) - sep = theme.default_separators(widget) - sep = sep if sep else False - width = theme.separator_block_width(widget) - width = width if width else 0 self._data.append({ u"full_text": " {} {} {}".format( theme.prefix(widget), @@ -65,8 +61,8 @@ class Output(bumblebee.output.Output): "background": theme.background(widget), "name": widget.module(), "instance": widget.instance(), - "separator": sep, - "separator_block_width": width, + "separator": theme.default_separators(widget, False), + "separator_block_width": theme.separator_block_width(widget, 0), }) theme.next_widget() diff --git a/bumblebee/theme.py b/bumblebee/theme.py index cd8d860..2f7d5c7 100644 --- a/bumblebee/theme.py +++ b/bumblebee/theme.py @@ -89,8 +89,8 @@ class Theme: def separator(self, widget): return self._get(widget, "separator") - def default_separators(self, widget): - return self._get(widget, "default-separators") + def default_separators(self, widget, default): + return self._get(widget, "default-separators", default) def separator_color(self, widget): return self.background(widget) @@ -98,8 +98,8 @@ class Theme: def separator_background(self, widget): return self._background[1] - def separator_block_width(self, widget): - return self._get(widget, "separator-block-width") + def separator_block_width(self, widget, default): + return self._get(widget, "separator-block-width", default) def _get(self, widget, name, default = None): module = widget.module() diff --git a/bumblebee/util.py b/bumblebee/util.py index c38bb79..3a6a60c 100644 --- a/bumblebee/util.py +++ b/bumblebee/util.py @@ -21,12 +21,13 @@ def durationfmt(duration): return res -def execute(cmd): +def execute(cmd, wait=True): args = shlex.split(cmd) p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - out, err = p.communicate() - if p.returncode != 0: - raise RuntimeError("{} exited with {}".format(cmd, p.returncode)) - - return out.decode("utf-8") + if wait: + out, err = p.communicate() + if p.returncode != 0: + raise RuntimeError("{} exited with {}".format(cmd, p.returncode)) + return out.decode("utf-8") + return None