From b5c2ca6ccf1caab45fd34f7e806abe02a4b08b1e Mon Sep 17 00:00:00 2001 From: tobi-wan-kenobi Date: Sat, 4 Apr 2020 14:37:19 +0200 Subject: [PATCH] [core/output] Add generic pango support Allow any piece of a theme that specifies a set of attributes (default, cycles, states, widgets) to use pango *instead* of the usual attributes. If pango is present, this will have precedence. A practical example of this can be found in the powerline-pango theme, which is added solely for demonstration purposes. fixes #531 --- core/output.py | 50 ++++++++++++++++++++++---- core/theme.py | 1 + doc/HOWTO_THEME.md | 3 ++ themes/powerline-pango.json | 70 +++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 6 deletions(-) create mode 100644 themes/powerline-pango.json diff --git a/core/output.py b/core/output.py index cde67c3..5ad1de0 100644 --- a/core/output.py +++ b/core/output.py @@ -74,21 +74,59 @@ class i3(object): return [] attr = self.__common_attributes(module, widget) attr.update({ - 'full_text': self.__theme.separator(), - 'color': self.__theme.bg(widget), - 'background': self.__theme.bg('previous'), '_decorator': True, }) + pango = self.__theme.pango(widget) + prev_pango = self.__theme.pango('previous') or {} + if pango: + pango = dict(pango) + if 'bgcolor' in pango: + pango['fgcolor'] = pango['bgcolor'] + del pango['bgcolor'] + if 'background' in pango: + pango['foreground'] = pango['background'] + del pango['background'] + if 'bgcolor' in prev_pango: + pango['bgcolor'] = prev_pango['bgcolor'] + if 'background' in prev_pango: + pango['background'] = prev_pango['background'] + + attr.update({ + 'full_text': self.__pango(self.__theme.separator(), pango), + 'markup': 'pango' + }) + else: + attr.update({ + 'full_text': self.__theme.separator(), + 'color': self.__theme.bg(widget), + 'background': self.__theme.bg('previous'), + }) return [attr] + def __pango(self, text, attributes): + result = '