From b163b21acee0bb22a5994b177e4e0c070c28ef32 Mon Sep 17 00:00:00 2001 From: gardenapple Date: Tue, 20 Jun 2023 13:36:48 +0300 Subject: [PATCH] More robust Hyprland backend --- src/modules/hyprland/backend.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/modules/hyprland/backend.cpp b/src/modules/hyprland/backend.cpp index 1e684d9..997fe11 100644 --- a/src/modules/hyprland/backend.cpp +++ b/src/modules/hyprland/backend.cpp @@ -181,17 +181,21 @@ std::string IPC::getSocket1Reply(const std::string& rq) { } char buffer[8192] = {0}; + std::string response; - sizeWritten = read(SERVERSOCKET, buffer, 8192); + do { + sizeWritten = read(SERVERSOCKET, buffer, 8192); - if (sizeWritten < 0) { - spdlog::error("Hyprland IPC: Couldn't read (5)"); - return ""; - } + if (sizeWritten < 0) { + spdlog::error("Hyprland IPC: Couldn't read (5)"); + close(SERVERSOCKET); + return ""; + } + response.append(buffer, sizeWritten); + } while (sizeWritten == 8192); close(SERVERSOCKET); - - return std::string(buffer); + return response; } } // namespace waybar::modules::hyprland