Skip to content

Commit

Permalink
Extract IPC code to separate method
Browse files Browse the repository at this point in the history
This makes it possible to use the same IPC code for more projects in the future
  • Loading branch information
aaronjamt authored Jan 29, 2025
1 parent 6131919 commit 016f1dd
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions hyprctl/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ int request(std::string arg, int minArgs = 0, bool needRoll = false) {
return 0;
}

int requestHyprpaper(std::string arg) {
int requestIPC(std::string filename, std::string arg) {
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);

if (SERVERSOCKET < 0) {
Expand All @@ -246,7 +246,7 @@ int requestHyprpaper(std::string arg) {

const std::string USERID = std::to_string(getUID());

std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/.hyprpaper.sock";
std::string socketPath = getRuntimeDir() + "/" + instanceSignature + "/" + filename;

strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);

Expand Down Expand Up @@ -281,6 +281,10 @@ int requestHyprpaper(std::string arg) {
return 0;
}

int requestHyprpaper(std::string arg) {
return requestIPC(".hyprpaper.sock", arg);
}

void batchRequest(std::string arg, bool json) {
std::string commands = arg.substr(arg.find_first_of(' ') + 1);

Expand Down

0 comments on commit 016f1dd

Please sign in to comment.