From 5a014305ec1d82952d22429bc218c1ad16e3ecc0 Mon Sep 17 00:00:00 2001 From: Viktar Lukashonak Date: Fri, 13 May 2022 22:58:00 +0300 Subject: [PATCH] Revert "Issue#1552. Calendar module, LC_TIME variable" This reverts commit 448b413eca7022be7580e28719ded6e0ee147694. --- src/modules/clock.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 86ffed2..92061f5 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -66,12 +66,17 @@ waybar::modules::Clock::Clock(const std::string& id, const Json::Value& config) } } - const char* applyLocale{config_["locale"].isString() ? config_["locale"].asCString() : getenv("LC_TIME")}; - try { - locale_ = applyLocale ? std::locale(applyLocale) : std::locale(""); - } catch(std::runtime_error const& localeE) { - spdlog::warn("Clock module. Wrong \"locale\" or LC_TIME variable(make sure locale is presented in /etc/locale.gen and generated by the locale-gen). Trace: {0}", localeE.what()); - locale_ = std::locale(); + if (config_["locale"].isString()) { + locale_ = std::locale(config_["locale"].asString()); + } else { + char* sysLocale{getenv("LC_TIME")}; + try { + locale_ = sysLocale ? std::locale(sysLocale) : std::locale(""); + } + catch(std::runtime_error const& localeErr) { + spdlog::warn(localeErr.what()); + locale_ = std::locale(); + } } thread_ = [this] {