Fix i3 bar bindings

Specifically:

- Do not log exceptions to the same location data is output.
- Fix format, i3bar is no longer using “pseudo-JSON”, also not sure whether it 
  ever used format `[[right list], [left list]]`, but it definitely does not 
  now.
- i3bgbar branch is no longer available.
- Yet i3wm supports background color, just with the different key (`background` 
  vs `background_color`).
This commit is contained in:
Foo 2017-05-11 21:09:10 +03:00
parent f6bf7b4916
commit 1e6414d0e8
3 changed files with 16 additions and 20 deletions

View File

@ -82,20 +82,11 @@ All ``powerline-lemonbar.py`` arguments:
I3 bar I3 bar
====== ======
.. note:: Add the following to :file:`~/.config/i3/config`::
As the patch to include background-colors in i3bar is likely not to be
merged, it is recommended to instead run ``bar`` (see above). The source for
i3bgbar is however still available `here
<https://github.com/S0lll0s/i3bgbar>`_.
Add the following to :file:`~/.i3/config`::
bar { bar {
i3bar_command i3bgbar
status_command python /path/to/powerline/bindings/i3/powerline-i3.py status_command python /path/to/powerline/bindings/i3/powerline-i3.py
font pango:PowerlineFont 12 font pango:PowerlineFont 12
} }
where ``i3bgbar`` may be replaced with the path to the custom i3bar binary and where ``PowerlineFont`` is any system font with powerline support.
``PowerlineFont`` is any system font with powerline support.

View File

@ -13,28 +13,34 @@ from powerline import Powerline
from powerline.lib.monotonic import monotonic from powerline.lib.monotonic import monotonic
class I3Powerline(Powerline):
'''Powerline child for i3bar
Currently only changes the default log target.
'''
default_log_stream = sys.stderr
if __name__ == '__main__': if __name__ == '__main__':
name = 'wm' name = 'wm'
if len(sys.argv) > 1: if len(sys.argv) > 1:
name = sys.argv[1] name = sys.argv[1]
powerline = Powerline(name, renderer_module='i3bar') powerline = I3Powerline(name, renderer_module='i3bar')
powerline.update_renderer() powerline.update_renderer()
interval = 0.5 interval = 0.5
print ('{"version": 1, "custom_workspace": true}') print ('{"version": 1}')
print ('[') print ('[')
print ('\t[[],[]]') print ('[]')
lock = Lock() lock = Lock()
def render(event=None, data=None, sub=None): def render(event=None, data=None, sub=None):
global lock global lock
with lock: with lock:
s = '[\n' + powerline.render(side='right')[:-2] + '\n]\n' print (',[' + powerline.render()[:-1] + ']')
s += ',[\n' + powerline.render(side='left')[:-2] + '\n]'
print (',[\n' + s + '\n]')
sys.stdout.flush() sys.stdout.flush()
sub = i3.Subscription(render, 'workspace') sub = i3.Subscription(render, 'workspace')

View File

@ -29,9 +29,8 @@ class I3barRenderer(Renderer):
segment['color'] = '#{0:06x}'.format(fg[1]) segment['color'] = '#{0:06x}'.format(fg[1])
if bg is not None: if bg is not None:
if bg is not False and bg[1] is not False: if bg is not False and bg[1] is not False:
segment['background_color'] = '#{0:06x}'.format(bg[1]) segment['background'] = '#{0:06x}'.format(bg[1])
# i3bar “pseudo json” requires one line at a time return json.dumps(segment) + ','
return json.dumps(segment) + ',\n'
renderer = I3barRenderer renderer = I3barRenderer