hyprctl: Extract IPC code to separate method (#9223)
This makes it possible to use the same IPC code for more projects in the future
This commit is contained in:
parent
ea16b64ec1
commit
7d51dee103
1 changed files with 6 additions and 2 deletions
|
|
@ -225,7 +225,7 @@ int request(std::string arg, int minArgs = 0, bool needRoll = false) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int requestHyprpaper(std::string arg) {
|
int requestIPC(std::string filename, std::string arg) {
|
||||||
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
|
const auto SERVERSOCKET = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
|
|
||||||
if (SERVERSOCKET < 0) {
|
if (SERVERSOCKET < 0) {
|
||||||
|
|
@ -243,7 +243,7 @@ int requestHyprpaper(std::string arg) {
|
||||||
|
|
||||||
const std::string USERID = std::to_string(getUID());
|
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);
|
strncpy(serverAddress.sun_path, socketPath.c_str(), sizeof(serverAddress.sun_path) - 1);
|
||||||
|
|
||||||
|
|
@ -278,6 +278,10 @@ int requestHyprpaper(std::string arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int requestHyprpaper(std::string arg) {
|
||||||
|
return requestIPC(".hyprpaper.sock", arg);
|
||||||
|
}
|
||||||
|
|
||||||
void batchRequest(std::string arg, bool json) {
|
void batchRequest(std::string arg, bool json) {
|
||||||
std::string commands = arg.substr(arg.find_first_of(' ') + 1);
|
std::string commands = arg.substr(arg.find_first_of(' ') + 1);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue