Merge branch 'update-qtile' into develop

This commit is contained in:
ZyX 2015-02-20 22:11:06 +03:00
commit 1445b5a655
3 changed files with 52 additions and 16 deletions

View File

@ -29,6 +29,13 @@ Due to fish having incorrect code for prompt width calculations up to version
(``%{…%}`` in zsh and ``\[…\]`` in bash prompts serve exactly this purpose)
users that have fish versions below 2.1 are not supported..
WM widgets requirements
^^^^^^^^^^^^^^^^^^^^^^^
Awesome is supported starting from version 3.5.1, inclusive. QTile is supported
from version 0.6, inclusive.
.. _usage-terminal-emulators:
Terminal emulator requirements

View File

@ -31,15 +31,20 @@ Add the following to :file:`~/.config/qtile/config.py`:
.. code-block:: python
from powerline.bindings.qtile.widget import Powerline
from libqtile.bar import Bar
from libqtile.config import Screen
from libqtile.widget import Spacer
from powerline.bindings.qtile.widget import PowerlineTextBox
screens = [
Screen(
top=bar.Bar([
# ...
Powerline(timeout=2),
# ...
top=Bar([
PowerlineTextBox(update_interval=2, side='left'),
Spacer(),
PowerlineTextBox(update_interval=2, side='right'),
],
35 # width
),
),
]

View File

@ -1,22 +1,32 @@
# vim:fileencoding=utf-8:noet
from __future__ import (unicode_literals, division, absolute_import, print_function)
from libqtile import bar
from libqtile.widget import base
from libqtile.bar import CALCULATED
from libqtile.widget import TextBox
from powerline import Powerline as PowerlineCore
from powerline import Powerline
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')
class QTilePowerline(Powerline):
def do_setup(self, obj):
obj.powerline = self
class PowerlineTextBox(TextBox):
# TODO Replace timeout argument with update_interval argument in next major
# release.
def __init__(self, timeout=2, text=b' ', width=CALCULATED, side='right', update_interval=None, **config):
super(PowerlineTextBox, self).__init__(text, width, **config)
self.side = side
self.update_interval = update_interval or 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='right')
self.text = self.powerline.render(side=self.side).encode('utf-8')
self.bar.draw()
return True
@ -26,12 +36,26 @@ class Powerline(base._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):
base._TextBox._configure(self, qtile, bar)
super(PowerlineTextBox, self)._configure(qtile, bar)
if self.layout.markup:
# QTile-0.9.1: no need to recreate layout or run timer_setup
return
self.layout = self.drawer.textlayout(
self.text,
self.foreground,
self.font,
self.fontsize,
self.fontshadow,
markup=True)
markup=True,
)
self.timer_setup()
# TODO: Remove this at next major release
Powerline = PowerlineTextBox