mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge pull request #1890 from eneshecan/master
This commit is contained in:
commit
e00e36981e
@ -50,17 +50,17 @@ auto Language::update() -> void {
|
||||
void Language::onEvent(const std::string& ev) {
|
||||
std::lock_guard<std::mutex> 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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user