[core/theme] Add support for foreground and background colors

Themes can now define "fg" and "bg" attributes that are used for
foreground (text) color and background color.

see #23
This commit is contained in:
Tobi-wan Kenobi 2016-12-09 08:58:45 +01:00
parent 0c7884d170
commit c52cb99518
6 changed files with 58 additions and 2 deletions

View file

@ -53,7 +53,9 @@ class I3BarOutput(object):
if suffix:
full_text = u"{}{}".format(full_text, suffix)
self._widgets.append({
u"full_text": u"{}".format(full_text)
u"full_text": u"{}".format(full_text),
"color": self._theme.fg(widget),
"background": self._theme.bg(widget),
})
def begin(self):

View file

@ -30,6 +30,14 @@ class Theme(object):
"""Return the theme suffix for a widget's full text"""
return self._get(widget, "suffix", None)
def fg(self, widget):
"""Return the foreground color for this widget"""
return self._get(widget, "fg", None)
def bg(self, widget):
"""Return the background color for this widget"""
return self._get(widget, "bg", None)
def loads(self, data):
"""Initialize the theme from a JSON string"""
theme = json.loads(data)