mirror of
https://github.com/powerline/powerline.git
synced 2025-07-31 01:35:40 +02:00
Merge branch 'update-qtile' into develop
This commit is contained in:
commit
1445b5a655
@ -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)
|
(``%{…%}`` in zsh and ``\[…\]`` in bash prompts serve exactly this purpose)
|
||||||
users that have fish versions below 2.1 are not supported..
|
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:
|
.. _usage-terminal-emulators:
|
||||||
|
|
||||||
Terminal emulator requirements
|
Terminal emulator requirements
|
||||||
|
@ -31,15 +31,20 @@ Add the following to :file:`~/.config/qtile/config.py`:
|
|||||||
|
|
||||||
.. code-block:: python
|
.. 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 = [
|
screens = [
|
||||||
Screen(
|
Screen(
|
||||||
top=bar.Bar([
|
top=Bar([
|
||||||
# ...
|
PowerlineTextBox(update_interval=2, side='left'),
|
||||||
Powerline(timeout=2),
|
Spacer(),
|
||||||
# ...
|
PowerlineTextBox(update_interval=2, side='right'),
|
||||||
],
|
],
|
||||||
|
35 # width
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -1,22 +1,32 @@
|
|||||||
# vim:fileencoding=utf-8:noet
|
# vim:fileencoding=utf-8:noet
|
||||||
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
from __future__ import (unicode_literals, division, absolute_import, print_function)
|
||||||
|
|
||||||
from libqtile import bar
|
from libqtile.bar import CALCULATED
|
||||||
from libqtile.widget import base
|
from libqtile.widget import TextBox
|
||||||
|
|
||||||
from powerline import Powerline as PowerlineCore
|
from powerline import Powerline
|
||||||
|
|
||||||
|
|
||||||
class Powerline(base._TextBox):
|
class QTilePowerline(Powerline):
|
||||||
def __init__(self, timeout=2, text=' ', width=bar.CALCULATED, **config):
|
def do_setup(self, obj):
|
||||||
base._TextBox.__init__(self, text, width, **config)
|
obj.powerline = self
|
||||||
self.timeout_add(timeout, self.update)
|
|
||||||
self.powerline = PowerlineCore(ext='wm', renderer_module='pango_markup')
|
|
||||||
|
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):
|
def update(self):
|
||||||
if not self.configured:
|
if not self.configured:
|
||||||
return True
|
return True
|
||||||
self.text = self.powerline.render(side='right')
|
self.text = self.powerline.render(side=self.side).encode('utf-8')
|
||||||
self.bar.draw()
|
self.bar.draw()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -26,12 +36,26 @@ class Powerline(base._TextBox):
|
|||||||
def cmd_get(self):
|
def cmd_get(self):
|
||||||
return self.text
|
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):
|
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.layout = self.drawer.textlayout(
|
||||||
self.text,
|
self.text,
|
||||||
self.foreground,
|
self.foreground,
|
||||||
self.font,
|
self.font,
|
||||||
self.fontsize,
|
self.fontsize,
|
||||||
self.fontshadow,
|
self.fontshadow,
|
||||||
markup=True)
|
markup=True,
|
||||||
|
)
|
||||||
|
self.timer_setup()
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Remove this at next major release
|
||||||
|
Powerline = PowerlineTextBox
|
||||||
|
Loading…
x
Reference in New Issue
Block a user