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 = (
|
||||
"location_code",
|
||||
("colorize", "Enable color with temperature and UTF-8 icons."),
|
||||
("units", "Celsius (metric) or Fahrenheit (imperial)"),
|
||||
"format",
|
||||
)
|
||||
@ -26,6 +27,14 @@ class Weather(IntervalModule):
|
||||
|
||||
units = "metric"
|
||||
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)
|
||||
def run(self):
|
||||
@ -34,7 +43,18 @@ class Weather(IntervalModule):
|
||||
temperature = conditions['temperature']
|
||||
humidity = conditions['humidity']
|
||||
units = result['units']
|
||||
color = None
|
||||
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 = {
|
||||
"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