fix(bspwm): Handle report strings with 3+ monitors
Fixes jaagr/lemonbuddy#54
This commit is contained in:
parent
d3a8ccbeac
commit
a55b7c3fd3
@ -125,10 +125,10 @@ bool BspwmModule::update()
|
|||||||
|
|
||||||
this->prev_data = data;
|
this->prev_data = data;
|
||||||
|
|
||||||
unsigned long n, m;
|
unsigned long pos;
|
||||||
|
|
||||||
while ((n = data.find("\n")) != std::string::npos)
|
while ((pos = data.find("\n")) != std::string::npos)
|
||||||
data.erase(n);
|
data.erase(pos);
|
||||||
|
|
||||||
if (data.empty())
|
if (data.empty())
|
||||||
return false;
|
return false;
|
||||||
@ -140,22 +140,20 @@ bool BspwmModule::update()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto needle_active = "M"+ this->monitor +":";
|
// Extract the string for the defined monitor
|
||||||
const auto needle_inactive = "m"+ this->monitor +":";
|
const auto needle_active = ":M"+ this->monitor +":";
|
||||||
|
const auto needle_inactive = ":m"+ this->monitor +":";
|
||||||
|
|
||||||
// Cut out the relevant section for the current monitor
|
if ((pos = data.find(prefix)) != std::string::npos)
|
||||||
if ((n = data.find(prefix + needle_active)) != std::string::npos) {
|
data = data.replace(pos, prefix.length(), ":");
|
||||||
if ((m = data.find(":m")) != std::string::npos) data = data.substr(n, m);
|
if ((pos = data.find(needle_active)) != std::string::npos)
|
||||||
} else if ((n = data.find(prefix + needle_inactive)) != std::string::npos) {
|
data.erase(0, pos+1);
|
||||||
if ((m = data.find(":M")) != std::string::npos) data = data.substr(n, m);
|
if ((pos = data.find(needle_inactive)) != std::string::npos)
|
||||||
} else if ((n = data.find(needle_active)) != std::string::npos) {
|
data.erase(0, pos+1);
|
||||||
data.erase(0, n);
|
if ((pos = data.find(":m", 1)) != std::string::npos)
|
||||||
} else if ((n = data.find(needle_inactive)) != std::string::npos) {
|
data.erase(pos);
|
||||||
data.erase(0, n);
|
if ((pos = data.find(":M", 1)) != std::string::npos)
|
||||||
}
|
data.erase(pos);
|
||||||
|
|
||||||
if (data.compare(0, prefix.length(), prefix) == 0)
|
|
||||||
data.erase(0, 1);
|
|
||||||
|
|
||||||
log_trace2(this->logger, data);
|
log_trace2(this->logger, data);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user