diff --git a/core/output.py b/core/output.py index 2b0ab2e..0d70a86 100644 --- a/core/output.py +++ b/core/output.py @@ -38,6 +38,18 @@ class i3(object): def stop(self): return { 'suffix': '\n]' } + def __pad(self, module, widget, full_text): + padding = self._theme.padding() + if not full_text: return padding + return '{}{}{}'.format(padding, full_text, padding) + + def __decorate(self, module, widget, full_text): + return '{}{}{}'.format( + self.__pad(module, widget, self._theme.prefix(widget)), + full_text, + self.__pad(module, widget, self._theme.suffix(widget)) + ) + def __common_attributes(self, module, widget): return { 'separator': self._theme.default_separators(), @@ -64,7 +76,7 @@ class i3(object): def __main(self, module, widget): attr = self.__common_attributes(module, widget) attr.update({ - 'full_text': widget.full_text(), + 'full_text': self.__decorate(module, widget, widget.full_text()), 'color': self._theme.fg(widget), 'background': self._theme.bg(widget), }) diff --git a/core/theme.py b/core/theme.py index a1d8a40..9f7dc8f 100644 --- a/core/theme.py +++ b/core/theme.py @@ -39,6 +39,8 @@ class Theme(object): ('border-bottom', 0), ('border-left', 0), ('border-right', 0), + ('padding', ''), + ('prefix', ''), ('suffix', ''), ]: setattr(self, attr.replace('-', '_'), lambda widget=None, default=default, attr=attr: self.__get(widget, attr, default)) @@ -77,6 +79,11 @@ class Theme(object): tmp = tmp[self.__widget_count % len(tmp)] value = tmp.get(key, value) + value = self.__data.get(key, value) + + if widget.module(): + value = self.__get(None, widget.module().name(), {}).get(key, value) + if not key in widget.state(): for state in widget.state(): theme = self.__get(widget, state, {}) diff --git a/core/widget.py b/core/widget.py index ab61d5c..43814bf 100644 --- a/core/widget.py +++ b/core/widget.py @@ -15,7 +15,9 @@ class Widget(util.store.Store, core.input.Object): return self._full_text(self) return self._full_text - def module(self, module): + def module(self, module=None): + if not module: + return self._module self._module = module def state(self): diff --git a/doc/NOTES.md b/doc/NOTES.md index 1ce031e..a36cf27 100644 --- a/doc/NOTES.md +++ b/doc/NOTES.md @@ -14,14 +14,12 @@ ## Backwards-compatibility - aliases -- icons (prefix/postfix) - charts (braille) - minimize modules - hide modules if not in warning/error state (-a) - WAL support / colorscheme support - tkinter / popups - scrolling decorator (incl. minwidth, alignment) -- states ## Improvements - pango output (improve - maybe autodetect? see #531)