summaryrefslogtreecommitdiff
path: root/hyprctl/main.cpp
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2023-08-13 21:42:11 +0200
committervaxerski <vaxry@vaxry.net>2023-08-13 21:42:16 +0200
commit3fc4ac07e05da41149363f4c03ec6ae657a13f2c (patch)
treefb24742869151b2b2d09959e7ece36f1ab07828c /hyprctl/main.cpp
parent38814e8a95cd59fe804eb75cf95e39a72ea592da (diff)
hyprctl: fix hyprpaper
Diffstat (limited to 'hyprctl/main.cpp')
-rw-r--r--hyprctl/main.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/hyprctl/main.cpp b/hyprctl/main.cpp
index 431f309d..6f418c05 100644
--- a/hyprctl/main.cpp
+++ b/hyprctl/main.cpp
@@ -193,20 +193,15 @@ void requestHyprpaper(std::string arg) {
return;
}
- // get the instance signature
- auto instanceSig = getenv("HYPRLAND_INSTANCE_SIGNATURE");
-
- if (!instanceSig) {
+ if (instanceSignature.empty()) {
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;
- std::string socketPath = "/tmp/hypr/" + instanceSigStr + "/.hyprpaper.sock";
+ std::string socketPath = "/tmp/hypr/" + instanceSignature + "/.hyprpaper.sock";
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
@@ -215,6 +210,9 @@ void requestHyprpaper(std::string arg) {
return;
}
+ arg = arg.substr(arg.find_first_of('/') + 1); // strip flags
+ arg = arg.substr(arg.find_first_of(' ') + 1); // strip "hyprpaper"
+
auto sizeWritten = write(SERVERSOCKET, arg.c_str(), arg.length());
if (sizeWritten < 0) {
@@ -430,7 +428,7 @@ int main(int argc, char** argv) {
else if (fullRequest.contains("/keyword"))
request(fullRequest, 2);
else if (fullRequest.contains("/hyprpaper"))
- request(fullRequest, 2);
+ requestHyprpaper(fullRequest);
else if (fullRequest.contains("/--help"))
printf("%s", USAGE.c_str());
else {