From 6f3b004199a6b1bb0a8f5431d677ab926bdf19f3 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Fri, 3 Jun 2022 17:41:57 +0200 Subject: IPC and log changes, introduce signature --- hyprctl/main.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'hyprctl/main.cpp') diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp index 60ee9606..d0c7d9ed 100644 --- a/hyprctl/main.cpp +++ b/hyprctl/main.cpp @@ -45,12 +45,25 @@ void request(std::string arg) { return; } + // get the instance signature + auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE"); + + if (!instanceSig) { + std::cout << "HYPRLAND_INSTANCE_SIGNATURE was not set! (Is Hyprland running?)"; + return; + } + + std::string instanceSigStr = std::string(instanceSig); + sockaddr_un serverAddress = {0}; serverAddress.sun_family = AF_UNIX; - strcpy(serverAddress.sun_path, "/tmp/hypr/.socket.sock"); + + std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.socket.sock"; + + strcpy(serverAddress.sun_path, socketPath.c_str()); if (connect(SERVERSOCKET, (sockaddr*)&serverAddress, SUN_LEN(&serverAddress)) < 0) { - std::cout << "Couldn't connect to /tmp/hypr/.socket.sock. (3) Is Hyprland running?"; + std::cout << "Couldn't connect to " << socketPath << ". (3)"; return; } -- cgit v1.2.3