Add Qtile widget

This commit is contained in:
Kim Silkebækken 2013-01-30 10:35:01 +01:00
parent fb929b76cc
commit 597f67b85a
3 changed files with 53 additions and 0 deletions

View File

@ -179,3 +179,23 @@ Then add the ``powerline_widget`` to your ``wibox``:
.. code-block:: lua
right_layout:add(powerline_widget)
Qtile widget
------------
Add the following to your :file:`~/.config/qtile/config.py`:
.. code-block:: python
from powerline.bindings.qtile.widget import Powerline
screens = [
Screen(
top=bar.Bar([
# ...
Powerline(timeout=2),
# ...
],
),
),
]

View File

View File

@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
from libqtile import bar
from libqtile.widget import base
from powerline.core import Powerline as PowerlineCore
class Powerline(base._TextBox):
def __init__(self, timeout=2, text=" ", width=bar.CALCULATED, **config):
base._TextBox.__init__(self, text, width, **config)
self.timeout_add(timeout, self.update)
self.powerline = PowerlineCore(ext='wm', renderer_module='pango_markup')
def update(self):
self.text = self.powerline.renderer.render(side='right')
self.bar.draw()
def cmd_update(self, text):
self.update(text)
def cmd_get(self):
return self.text
def _configure(self, qtile, bar):
base._TextBox._configure(self, qtile, bar)
self.layout = self.drawer.textlayout(
self.text,
self.foreground,
self.font,
self.fontsize,
self.fontshadow,
markup=True)