diff --git a/powerline/config_files/colors.json b/powerline/config_files/colors.json index ca0b7a71..3bbb90f2 100644 --- a/powerline/config_files/colors.json +++ b/powerline/config_files/colors.json @@ -89,6 +89,10 @@ "yellow_orange_red": [ [3, 9, 1], ["b58900", "b58700", "b58600", "b68501", "b68401", "b78202", "b78102", "b88003", "b87f03", "b87d03", "b97c04", "b97b04", "ba7a05", "ba7805", "bb7706", "bb7606", "bc7507", "bc7307", "bc7207", "bd7108", "bd7008", "be6e09", "be6d09", "bf6c0a", "bf6b0a", "c06a0b", "c0680b", "c0670b", "c1660c", "c1650c", "c2630d", "c2620d", "c3610e", "c3600e", "c35e0e", "c45d0f", "c45c0f", "c55b10", "c55910", "c65811", "c65711", "c75612", "c75412", "c75312", "c85213", "c85113", "c94f14", "c94e14", "ca4d15", "ca4c15", "cb4b16", "cb4a16", "cb4a17", "cc4917", "cc4918", "cc4818", "cd4819", "cd4719", "cd471a", "ce461a", "ce461b", "ce451b", "cf451c", "cf441c", "cf441d", "d0431d", "d0431e", "d0421e", "d1421f", "d1411f", "d14120", "d24020", "d24021", "d23f21", "d33f22", "d33e22", "d33e23", "d43d23", "d43d24", "d43c24", "d53c25", "d53b25", "d53b26", "d63a26", "d63a27", "d63927", "d73928", "d73828", "d73829", "d83729", "d8372a", "d8362a", "d9362b", "d9352b", "d9352c", "da342c", "da342d", "da332d", "db332e"] + ], + "blue_red": [ + [39, 74, 68, 67, 103, 97, 96, 132, 131, 167, 203, 197], + ["19b4fe", "1bb2fc", "1db1fa", "1faff8", "22aef6", "24adf4", "26abf2", "29aaf0", "2ba9ee", "2da7ec", "30a6ea", "32a5e8", "34a3e6", "36a2e4", "39a0e2", "3b9fe1", "3d9edf", "409cdd", "429bdb", "449ad9", "4798d7", "4997d5", "4b96d3", "4d94d1", "5093cf", "5292cd", "5490cb", "578fc9", "598dc7", "5b8cc6", "5e8bc4", "6089c2", "6288c0", "6487be", "6785bc", "6984ba", "6b83b8", "6e81b6", "7080b4", "727eb2", "757db0", "777cae", "797aac", "7b79ab", "7e78a9", "8076a7", "8275a5", "8574a3", "8772a1", "89719f", "8c709d", "8e6e9b", "906d99", "926b97", "956a95", "976993", "996791", "9c668f", "9e658e", "a0638c", "a3628a", "a56188", "a75f86", "a95e84", "ac5c82", "ae5b80", "b05a7e", "b3587c", "b5577a", "b75678", "ba5476", "bc5374", "be5273", "c05071", "c34f6f", "c54e6d", "c74c6b", "ca4b69", "cc4967", "ce4865", "d14763", "d34561", "d5445f", "d7435d", "da415b", "dc4059", "de3f58", "e13d56", "e33c54", "e53a52", "e83950", "ea384e", "ec364c", "ee354a", "f13448", "f33246", "f53144", "f83042", "fa2e40"] ] } } diff --git a/powerline/config_files/colorschemes/tmux/default.json b/powerline/config_files/colorschemes/tmux/default.json index 67be9993..8b7ba787 100644 --- a/powerline/config_files/colorschemes/tmux/default.json +++ b/powerline/config_files/colorschemes/tmux/default.json @@ -9,8 +9,7 @@ "email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] }, "hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] }, "weather": { "fg": "gray8", "bg": "gray0" }, - "weather_temp_cold": { "fg": "steelblue", "bg": "gray0" }, - "weather_temp_hot": { "fg": "darkorange3", "bg": "gray0" }, + "weather_temp_gradient": { "fg": "blue_red", "bg": "gray0" }, "weather_condition_hot": { "fg": "khaki1", "bg": "gray0" }, "weather_condition_snowy": { "fg": "skyblue1", "bg": "gray0" }, "weather_condition_rainy": { "fg": "skyblue1", "bg": "gray0" }, diff --git a/powerline/config_files/colorschemes/wm/default.json b/powerline/config_files/colorschemes/wm/default.json index 90bd6cc4..ab1ee74b 100644 --- a/powerline/config_files/colorschemes/wm/default.json +++ b/powerline/config_files/colorschemes/wm/default.json @@ -9,8 +9,7 @@ "email_alert": { "fg": "white", "bg": "brightred", "attr": ["bold"] }, "hostname": { "fg": "black", "bg": "gray10", "attr": ["bold"] }, "weather": { "fg": "gray8", "bg": "gray0" }, - "weather_temp_cold": { "fg": "steelblue", "bg": "gray0" }, - "weather_temp_hot": { "fg": "darkorange3", "bg": "gray0" }, + "weather_temp_gradient": { "fg": "blue_red", "bg": "gray0" }, "weather_condition_hot": { "fg": "khaki1", "bg": "gray0" }, "weather_condition_snowy": { "fg": "skyblue1", "bg": "gray0" }, "weather_condition_rainy": { "fg": "skyblue1", "bg": "gray0" }, diff --git a/powerline/segments/common.py b/powerline/segments/common.py index dfa1a3ae..c1d89f6e 100644 --- a/powerline/segments/common.py +++ b/powerline/segments/common.py @@ -356,6 +356,12 @@ class WeatherSegment(ThreadedSegment): temperature_format = temperature_format or ('{temp:.0f}' + temp_units[unit]) temp = temp_conversions[unit](self.temp) + if self.temp < -30: + gradient_level = 0 + elif self.temp > 40: + gradient_level = 100 + else: + gradient_level = int((self.temp + 30) * 100 // 70) groups = ['weather_condition_' + icon_name for icon_name in self.icon_names] + ['weather_conditions', 'weather'] return [ { @@ -365,9 +371,10 @@ class WeatherSegment(ThreadedSegment): }, { 'contents': temperature_format.format(temp=temp), - 'highlight_group': ['weather_temp_cold' if int(self.temp) < 0 else 'weather_temp_hot', 'weather_temp', 'weather'], + 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'draw_divider': False, 'divider_highlight_group': 'background:divider', + 'gradient_level': gradient_level, }, ] @@ -393,7 +400,7 @@ weather conditions. Divider highlight group used: ``background:divider``. -Highlight groups used: ``weather_conditions`` or ``weather``, ``weather_temp_cold`` or ``weather_temp_hot`` or ``weather_temp`` or ``weather``. +Highlight groups used: ``weather_conditions`` or ``weather``, ``weather_temp_gradient`` (gradient) or ``weather``. Also uses ``weather_conditions_{condition}`` for all weather conditions supported by Yahoo. ''') diff --git a/tests/test_segments.py b/tests/test_segments.py index 6eedcbae..c5f3e1c0 100644 --- a/tests/test_segments.py +++ b/tests/test_segments.py @@ -143,27 +143,27 @@ class TestCommon(TestCase): with replace_module_attr(common, 'urllib_read', urllib_read): self.assertEqual(common.weather(), [ {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, - {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_cold', 'weather_temp', 'weather'], 'contents': '-11°C'} + {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-11°C'} ]) self.assertEqual(common.weather(icons={'cloudy': 'o'}), [ {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'o '}, - {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_cold', 'weather_temp', 'weather'], 'contents': '-11°C'} + {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-11°C'} ]) self.assertEqual(common.weather(icons={'partly_cloudy_day': 'x'}), [ {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': 'x '}, - {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_cold', 'weather_temp', 'weather'], 'contents': '-11°C'} + {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-11°C'} ]) self.assertEqual(common.weather(unit='F'), [ {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, - {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_cold', 'weather_temp', 'weather'], 'contents': '12°F'} + {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '12°F'} ]) self.assertEqual(common.weather(unit='K'), [ {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, - {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_cold', 'weather_temp', 'weather'], 'contents': '262K'} + {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '262K'} ]) self.assertEqual(common.weather(temperature_format='{temp:.1e}C'), [ {'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_condition_partly_cloudy_day', 'weather_condition_cloudy', 'weather_conditions', 'weather'], 'contents': '☁ '}, - {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_cold', 'weather_temp', 'weather'], 'contents': '-1.1e+01C'} + {'draw_divider': False, 'divider_highlight_group': 'background:divider', 'highlight_group': ['weather_temp_gradient', 'weather_temp', 'weather'], 'contents': '-1.1e+01C'} ]) def test_system_load(self):