weatherstatus: Display hourglass if we could not fetch new data.

This commit is contained in:
tastytea 2021-08-23 17:39:27 +02:00
parent f24a23e5e5
commit 0c094f9f55
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 11 additions and 4 deletions

View File

@ -39,6 +39,7 @@ struct weather
{
float temperature{-273.15};
std::string icon{""};
bool old{true};
} __attribute__((aligned(64))) weather; // NOLINT(cert-err58-cpp)
std::mutex mutex_weather;
@ -137,9 +138,14 @@ bool fetch_weather()
weather.temperature = json[0]["main"]["temp"].get<float>();
weather.icon = map_icon(
json[0]["weather"][0]["icon"].get<std::string_view>());
return true;
weather.old = false;
}
return false;
else
{
weather.old = true;
}
return true;
}
void print_weather()
@ -164,8 +170,9 @@ void print_weather()
return "#66ff66";
}()};
std::cout << format(R"({0:s} <span color="{1:s}">{2:.1f}°C</span>)",
weather.icon, color, weather.temperature)
std::cout << format(R"({0:s} <span color="{1:s}">{2:.1f}°C</span>{3:s})",
weather.icon, color, weather.temperature,
weather.old ? R"( <span color="red">⏳</span>)" : "")
<< std::endl;
}