Waybar/include/modules/sway/ipc/client.hpp

34 lines
772 B
C++
Raw Normal View History

2018-08-08 21:54:58 +00:00
#pragma once
#include <iostream>
#include "ipc.hpp"
/**
* IPC response including type of IPC response, size of payload and the json
* encoded payload string.
*/
struct ipc_response {
uint32_t size;
uint32_t type;
std::string payload;
};
/**
* Gets the path to the IPC socket from sway.
*/
2018-08-16 12:29:41 +00:00
std::string getSocketPath(void);
2018-08-08 21:54:58 +00:00
/**
* Opens the sway socket.
*/
2018-08-16 12:29:41 +00:00
int ipcOpenSocket(const std::string &socketPath);
2018-08-08 21:54:58 +00:00
/**
* Issues a single IPC command and returns the buffer. len will be updated with
* the length of the buffer returned from sway.
*/
2018-08-18 14:01:56 +00:00
struct ipc_response ipcSingleCommand(int socketfd, uint32_t type,
const std::string& payload);
2018-08-08 21:54:58 +00:00
/**
* Receives a single IPC response and returns an ipc_response.
*/
2018-08-16 12:29:41 +00:00
struct ipc_response ipcRecvResponse(int socketfd);