statusweather: Add night symbols, change some symbols.

The only day→night change at the moment is for clear sky.
This commit is contained in:
tastytea 2021-08-23 22:53:10 +02:00
parent 5356547d49
commit 1a2aa46ba2
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
1 changed files with 19 additions and 12 deletions

View File

@ -36,6 +36,7 @@
#include <string_view> #include <string_view>
#include <thread> #include <thread>
#include <tuple> #include <tuple>
#include <utility>
struct weather struct weather
{ {
@ -48,22 +49,28 @@ std::mutex mutex_weather;
std::string map_icon(const std::string_view icon_id) std::string map_icon(const std::string_view icon_id)
{ {
// <https://openweathermap.org/weather-conditions> // <https://openweathermap.org/weather-conditions>
const std::map<std::uint8_t, std::string> icons{{{1, "🌞"}, // NOTE: There does not seem to be weather emojis with the moon in unicode.
{2, ""}, const std::map<std::uint8_t, std::pair<std::string, std::string>> icons{
{3, ""}, {{1, {"🌞", "🌝"}}, // clear sky
{4, ""}, {2, {"🌤", "🌤"}}, // few clouds
{9, "🌧"}, {3, {"", ""}}, // scattered clouds
{10, "🌧"}, {4, {"", ""}}, // broken clouds
{10, ""}, {9, {"🌧", "🌧"}}, // shower rain
{13, "🌨"}, {10, {"🌧", "🌧"}}, // rain
{50, "🌫"}}}; {10, {"🌩", "🌩"}}, // thunderstorm
// TODO: Differenciate between day and night. {13, {"🌨", "🌨"}}, // snow
{50, {"🌫", "🌫"}}}}; // mist
const auto icon{icons.find(std::stoul(icon_id.data()))}; const auto icon{icons.find(std::stoul(icon_id.data()))};
if (icon != icons.end()) if (icon != icons.end())
{ {
return icon->second; if (*icon_id.rbegin() == 'n') // Night
{
return icon->second.second;
}
return icon->second.first;
} }
return {}; return "";
} }
std::tuple<std::string, std::string> get_options() std::tuple<std::string, std::string> get_options()