mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
fix(bar): handle ipc connection errors.
Try to use the default bar id (`bar-0`) if none is set.
This commit is contained in:
@ -3,6 +3,8 @@
|
||||
#include <fmt/ostream.h>
|
||||
#include <spdlog/spdlog.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include "bar.hpp"
|
||||
#include "modules/sway/ipc/ipc.hpp"
|
||||
|
||||
@ -47,13 +49,13 @@ struct swaybar_config parseConfig(const Json::Value& payload) {
|
||||
}
|
||||
|
||||
void BarIpcClient::onInitialConfig(const struct Ipc::ipc_response& res) {
|
||||
try {
|
||||
auto payload = parser_.parse(res.payload);
|
||||
auto config = parseConfig(payload);
|
||||
onConfigUpdate(config);
|
||||
} catch (const std::exception& e) {
|
||||
spdlog::error("BarIpcClient::onInitialConfig {}", e.what());
|
||||
auto payload = parser_.parse(res.payload);
|
||||
if (auto success = payload.get("success", true); !success.asBool()) {
|
||||
auto err = payload.get("error", "Unknown error");
|
||||
throw std::runtime_error(err.asString());
|
||||
}
|
||||
auto config = parseConfig(payload);
|
||||
onConfigUpdate(config);
|
||||
}
|
||||
|
||||
void BarIpcClient::onIpcEvent(const struct Ipc::ipc_response& res) {
|
||||
|
Reference in New Issue
Block a user