diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:40:16 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 16:40:16 +0000 |
commit | 3f25952c13d5847d510c0cae22a8ba876638d570 (patch) | |
tree | 02f505f016ed5a1029277dcae520d5e2a75906fb /powerline/renderers/i3bar.py | |
parent | Initial commit. (diff) | |
download | powerline-3f25952c13d5847d510c0cae22a8ba876638d570.tar.xz powerline-3f25952c13d5847d510c0cae22a8ba876638d570.zip |
Adding upstream version 2.8.3.upstream/2.8.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'powerline/renderers/i3bar.py')
-rw-r--r-- | powerline/renderers/i3bar.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/powerline/renderers/i3bar.py b/powerline/renderers/i3bar.py new file mode 100644 index 0000000..3eab61f --- /dev/null +++ b/powerline/renderers/i3bar.py @@ -0,0 +1,36 @@ +# vim:fileencoding=utf-8:noet +from __future__ import (unicode_literals, division, absolute_import, print_function) + +import json + +from powerline.renderer import Renderer + + +class I3barRenderer(Renderer): + '''I3bar Segment Renderer. + + Currently works only for i3bgbar (i3 bar with custom patches). + ''' + + @staticmethod + def hlstyle(*args, **kwargs): + # We don’t need to explicitly reset attributes, so skip those calls + return '' + + def hl(self, contents, fg=None, bg=None, attrs=None, **kwargs): + segment = { + 'full_text': contents, + 'separator': False, + 'separator_block_width': 0, # no separators + } + + if fg is not None: + if fg is not False and fg[1] is not False: + segment['color'] = '#{0:06x}'.format(fg[1]) + if bg is not None: + if bg is not False and bg[1] is not False: + segment['background'] = '#{0:06x}'.format(bg[1]) + return json.dumps(segment) + ',' + + +renderer = I3barRenderer |