Merge branch 'weather_color' of https://github.com/dubwoc/i3pystatus
This commit is contained in:
commit
19e5a87f2f
@ -19,6 +19,7 @@ class Weather(IntervalModule):
|
|||||||
|
|
||||||
settings = (
|
settings = (
|
||||||
"location_code",
|
"location_code",
|
||||||
|
("colorize", "Enable color with temperature and UTF-8 icons."),
|
||||||
("units", "Celsius (metric) or Fahrenheit (imperial)"),
|
("units", "Celsius (metric) or Fahrenheit (imperial)"),
|
||||||
"format",
|
"format",
|
||||||
)
|
)
|
||||||
@ -26,6 +27,14 @@ class Weather(IntervalModule):
|
|||||||
|
|
||||||
units = "metric"
|
units = "metric"
|
||||||
format = "{current_temp}"
|
format = "{current_temp}"
|
||||||
|
colorize = None
|
||||||
|
color_icons = {'Fair': (u'\u2600', '#FFCC00'),
|
||||||
|
'Cloudy': (u'\u2601', '#F8F8FF'),
|
||||||
|
'Rainy': (u'\u2614', '#CBD2C0'),
|
||||||
|
'Sunny': (u'\u263C', '#FFFF00'),
|
||||||
|
'Snow': (u'\u2603', '#FFFFFF'),
|
||||||
|
'default': ('', None),
|
||||||
|
}
|
||||||
|
|
||||||
@require(internet)
|
@require(internet)
|
||||||
def run(self):
|
def run(self):
|
||||||
@ -34,7 +43,18 @@ class Weather(IntervalModule):
|
|||||||
temperature = conditions['temperature']
|
temperature = conditions['temperature']
|
||||||
humidity = conditions['humidity']
|
humidity = conditions['humidity']
|
||||||
units = result['units']
|
units = result['units']
|
||||||
|
color = None
|
||||||
current_temp = '{t}°{d} '.format(t=temperature, d=units['temperature'])
|
current_temp = '{t}°{d} '.format(t=temperature, d=units['temperature'])
|
||||||
|
|
||||||
|
if self.colorize:
|
||||||
|
icon, color = self.color_icons.get(conditions['text'],
|
||||||
|
self.color_icons['default'])
|
||||||
|
current_temp = '{t}°{d} {i}'.format(t=temperature,
|
||||||
|
d=units['temperature'],
|
||||||
|
i=icon)
|
||||||
|
color = color
|
||||||
|
|
||||||
self.output = {
|
self.output = {
|
||||||
"full_text": self.format.format(current_temp=current_temp, humidity=humidity)
|
"full_text": self.format.format(current_temp=current_temp, humidity=humidity),
|
||||||
|
"color": color
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user