Fix MPD, add missing while loop

This commit is contained in:
Alex 2020-08-06 21:57:02 +02:00 committed by GitHub
parent 4d6e20a96d
commit a446cd692d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,20 +63,22 @@ auto waybar::modules::MPD::update() -> void {
std::thread waybar::modules::MPD::event_listener() { std::thread waybar::modules::MPD::event_listener() {
return std::thread([this] { return std::thread([this] {
try { while (true) {
if (connection_ == nullptr) { try {
// Retry periodically if no connection if (connection_ == nullptr) {
dp.emit(); // Retry periodically if no connection
std::this_thread::sleep_for(interval_); dp.emit();
} else { std::this_thread::sleep_for(interval_);
waitForEvent(); } else {
dp.emit(); waitForEvent();
} dp.emit();
} catch (const std::exception& e) { }
if (strcmp(e.what(), "Connection to MPD closed") == 0) { } catch (const std::exception& e) {
spdlog::debug("{}: {}", module_name_, e.what()); if (strcmp(e.what(), "Connection to MPD closed") == 0) {
} else { spdlog::debug("{}: {}", module_name_, e.what());
spdlog::warn("{}: {}", module_name_, e.what()); } else {
spdlog::warn("{}: {}", module_name_, e.what());
}
} }
} }
}); });