From 4136ffaecb067b6bf93c66d6b9c9783316dfd6f9 Mon Sep 17 00:00:00 2001 From: Enes Hecan Date: Fri, 16 Dec 2022 10:01:58 +0100 Subject: [PATCH] Minor refactorings and formatting fixes for hyprland language module --- src/modules/hyprland/language.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/modules/hyprland/language.cpp b/src/modules/hyprland/language.cpp index 738c835c..19a06328 100644 --- a/src/modules/hyprland/language.cpp +++ b/src/modules/hyprland/language.cpp @@ -50,17 +50,17 @@ auto Language::update() -> void { void Language::onEvent(const std::string& ev) { std::lock_guard lg(mutex_); auto layoutName = ev.substr(ev.find_last_of(',') + 1); - auto keebName = ev.substr(0, ev.find_last_of(',')); - keebName = keebName.substr(keebName.find_first_of('>') + 2); + auto kbName = ev.substr(0, ev.find_last_of(',')); + kbName = kbName.substr(kbName.find_first_of('>') + 2); - if (config_.isMember("keyboard-name") && keebName != config_["keyboard-name"].asString()) + if (config_.isMember("keyboard-name") && kbName != config_["keyboard-name"].asString()) return; // ignore - const auto BRIEFNAME = getShortFrom(layoutName); + const auto briefName = getShortFrom(layoutName); - if (config_.isMember("format-" + BRIEFNAME)) { - const auto PROPNAME = "format-" + BRIEFNAME; - layoutName = fmt::format(format_, config_[PROPNAME].asString()); + if (config_.isMember("format-" + briefName)) { + const auto propName = "format-" + briefName; + layoutName = fmt::format(format_, config_[propName].asString()); } else { layoutName = fmt::format(format_, layoutName); } @@ -77,21 +77,23 @@ void Language::onEvent(const std::string& ev) { } void Language::initLanguage() { - const auto INPUTDEVICES = gIPC->getSocket1Reply("devices"); + const auto inputDevices = gIPC->getSocket1Reply("devices"); - const auto KEEBNAME = config_["keyboard-name"].asString(); + const auto kbName = config_["keyboard-name"].asString(); try { - auto searcher = KEEBNAME.empty() ? INPUTDEVICES : INPUTDEVICES.substr(INPUTDEVICES.find(KEEBNAME) + KEEBNAME.length()); + auto searcher = kbName.empty() + ? inputDevices + : inputDevices.substr(inputDevices.find(kbName) + kbName.length()); searcher = searcher.substr(searcher.find("keymap:") + 8); searcher = searcher.substr(0, searcher.find_first_of("\n\t")); auto layoutName = std::string{}; - const auto BRIEFNAME = getShortFrom(searcher); + const auto briefName = getShortFrom(searcher); - if (config_.isMember("format-" + BRIEFNAME)) { - const auto PROPNAME = "format-" + BRIEFNAME; - layoutName = fmt::format(format_, config_[PROPNAME].asString()); + if (config_.isMember("format-" + briefName)) { + const auto propName = "format-" + briefName; + layoutName = fmt::format(format_, config_[propName].asString()); } else { layoutName = fmt::format(format_, searcher); }