diff --git a/powerline/bindings/qtile/widget.py b/powerline/bindings/qtile/widget.py index 829faf4d..51812a03 100644 --- a/powerline/bindings/qtile/widget.py +++ b/powerline/bindings/qtile/widget.py @@ -15,15 +15,16 @@ class QTilePowerline(Powerline): class PowerlineTextBox(TextBox): def __init__(self, timeout=2, text=' ', width=CALCULATED, side='right', **config): super(PowerlineTextBox, self).__init__(text, width, **config) - self.timeout_add(timeout, self.update) self.side = side + self.update_interval = timeout + self.did_run_timer_setup = False powerline = QTilePowerline(ext='wm', renderer_module='pango_markup') powerline.setup(self) def update(self): if not self.configured: return True - self.text = self.powerline.render(side=self.side) + self.text = self.powerline.render(side=self.side).encode('utf-8') self.bar.draw() return True @@ -33,6 +34,11 @@ class PowerlineTextBox(TextBox): def cmd_get(self): return self.text + def timer_setup(self): + if not self.did_run_timer_setup: + self.did_run_timer_setup = True + self.timeout_add(self.update_interval, self.update) + def _configure(self, qtile, bar): super(PowerlineTextBox, self)._configure(qtile, bar) self.layout = self.drawer.textlayout( @@ -43,6 +49,7 @@ class PowerlineTextBox(TextBox): self.fontshadow, markup=True, ) + self.timer_setup() # TODO: Remove this at next major release