[themes] Add support for generic warning/critical colors
Font and background colors for warning and critical elements can now be specified using fg-warning, fg-critical, bg-warning and bg-critical. Also, optionally, the "urgent" flag will be set towards the i3bar, if possible.
This commit is contained in:
parent
6278a4e564
commit
14bce293eb
5 changed files with 40 additions and 3 deletions
|
@ -6,6 +6,12 @@ class Module(object):
|
|||
def data(self):
|
||||
pass
|
||||
|
||||
def critical(self):
|
||||
return False
|
||||
|
||||
def warning(self):
|
||||
return False
|
||||
|
||||
def state(self):
|
||||
return "default"
|
||||
|
||||
|
|
|
@ -18,7 +18,15 @@ class Module(bumblebee.module.Module):
|
|||
with open("/sys/class/power_supply/{}/status".format(self._battery)) as f:
|
||||
self._status = f.read().strip()
|
||||
if self._status == "Discharging":
|
||||
return "discharging"
|
||||
if self._capacity < 10:
|
||||
return "discharging_critical"
|
||||
if self._capacity < 25:
|
||||
return "discharging_low"
|
||||
if self._capacity < 50:
|
||||
return "discharging_medium"
|
||||
if self._capacity < 75:
|
||||
return "discharging_high"
|
||||
return "discharging_full"
|
||||
else:
|
||||
return "charging"
|
||||
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
|
||||
|
|
|
@ -20,6 +20,10 @@ class i3bar(bumblebee.output.Output):
|
|||
"color": theme.color(obj),
|
||||
"background": theme.background(obj),
|
||||
}
|
||||
|
||||
if theme.urgent(obj) and obj.critical():
|
||||
data["urgent"] = True
|
||||
|
||||
if theme.default_separators(obj) == False:
|
||||
data["separator"] = False
|
||||
data["separator_block_width"] = 0
|
||||
|
|
|
@ -37,6 +37,9 @@ class Theme:
|
|||
self._previous_background = None
|
||||
self._background = None
|
||||
|
||||
def urgent(self, obj):
|
||||
self._gettheme(obj, "urgent")
|
||||
|
||||
def next(self):
|
||||
self._cycle_index += 1
|
||||
self._previous_background = self._background
|
||||
|
@ -44,10 +47,25 @@ class Theme:
|
|||
self._cycle_index = 0
|
||||
|
||||
def color(self, obj):
|
||||
return self._gettheme(obj, "fg")
|
||||
fg = None
|
||||
if obj.warning():
|
||||
fg = self._gettheme(obj, "fg-warning")
|
||||
if obj.critical():
|
||||
fg = self._gettheme(obj, "fg-critical")
|
||||
if fg == None:
|
||||
fg = self._gettheme(obj, "fg")
|
||||
return fg
|
||||
|
||||
def background(self, obj):
|
||||
self._background = self._gettheme(obj, "bg")
|
||||
self._background = None
|
||||
if obj.warning():
|
||||
self._background = self._gettheme(obj, "bg-warning")
|
||||
if obj.critical():
|
||||
self._background = self._gettheme(obj, "bg-critical")
|
||||
|
||||
if self._background == None:
|
||||
self._background = self._gettheme(obj, "bg")
|
||||
|
||||
return self._background
|
||||
|
||||
def previous_background(self):
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"defaults": {
|
||||
"urgent": true,
|
||||
"prefix": " ",
|
||||
"suffix" : " ",
|
||||
"cycle": [
|
||||
|
|
Loading…
Reference in a new issue