#pragma once #include #include #include #include #include "helpers/command.hpp" class HyprctlHelper { public: static nlohmann::json getMonitorData() { std::string result = CommandHelper::exec("hyprctl -j monitors"); assert(!result.empty() && "Failed to get monitor data from hyprctl"); auto json = nlohmann::json::parse(result); assert(json.is_array()); return json; } static nlohmann::json getWorkspaceData() { std::string result = CommandHelper::exec("hyprctl -j workspaces"); assert(!result.empty() && "Failed to get workspace data from hyprctl"); auto json = nlohmann::json::parse(result); assert(json.is_array()); return json; } static nlohmann::json getClientData() { std::string result = CommandHelper::exec("hyprctl -j clients"); assert(!result.empty() && "Failed to get client data from hyprctl"); auto json = nlohmann::json::parse(result); assert(json.is_array()); return json; } static void dispatchWorkspace(int workspaceNumber) { std::string out = "hyprctl dispatch workspace " + std::to_string(workspaceNumber); CommandHelper::execNoOutput(out.c_str()); } }; class HyprSocketHelper { public: static std::string getHyprlandSocketPath() { const char *hyprlandInstanceSignature = std::getenv("HYPRLAND_INSTANCE_SIGNATURE"); const char *xdgRuntimeDir = std::getenv("XDG_RUNTIME_DIR"); if (!xdgRuntimeDir || !hyprlandInstanceSignature) { return std::string(); } std::string basePath = std::string(xdgRuntimeDir) + "/hypr/" + std::string(hyprlandInstanceSignature) + "/"; std::string sock1 = basePath + ".socket2.sock"; if (access(sock1.c_str(), F_OK) == 0) { return sock1; } return std::string(); } };