Merge pull request #1888 from eneshecan/master

Fixes undefined
This commit is contained in:
Alex 2022-12-16 09:20:49 +01:00 committed by GitHub
commit bd199e414b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -79,16 +79,26 @@ void Language::onEvent(const std::string& ev) {
void Language::initLanguage() {
const auto INPUTDEVICES = gIPC->getSocket1Reply("devices");
if (!config_.isMember("keyboard-name")) return;
const auto KEEBNAME = config_["keyboard-name"].asString();
try {
auto searcher = INPUTDEVICES.substr(INPUTDEVICES.find(KEEBNAME) + KEEBNAME.length());
searcher = searcher.substr(searcher.find("keymap:") + 7);
auto searcher = KEEBNAME.empty() ? INPUTDEVICES : INPUTDEVICES.substr(INPUTDEVICES.find(KEEBNAME) + KEEBNAME.length());
searcher = searcher.substr(searcher.find("keymap:") + 8);
searcher = searcher.substr(0, searcher.find_first_of("\n\t"));
layoutName_ = searcher;
auto layoutName = std::string{};
const auto BRIEFNAME = getShortFrom(searcher);
if (config_.isMember("format-" + BRIEFNAME)) {
const auto PROPNAME = "format-" + BRIEFNAME;
layoutName = fmt::format(format_, config_[PROPNAME].asString());
} else {
layoutName = fmt::format(format_, searcher);
}
layoutName = waybar::util::sanitize_string(layoutName);
layoutName_ = layoutName;
spdlog::debug("hyprland language initLanguage found {}", layoutName_);