dwm/IPCClient.h
mihirlad55 4a230d362a [PATCH] Add IPC support through a unix socket
This patch currently supports the following requests:
* Run custom commands with arguments (similar to key bind functions)
* Get monitor properties
* Get all available layouts
* Get available tags
* Get client properties
* Subscribe to tag change, client focus change, and layout change,
  monitor focus change, focused title change, and client state change
  events

This patch includes a dwm-msg cli program that supports all of the
above requests for easy integration into shell scripts.

The messages are sent in a JSON format to promote integration to
increase scriptability in languages like Python/JavaScript.

The patch requires YAJL for JSON parsing and a system with epoll
support. Portability is planned to be increased in the future.

This patch is best applied after all other patches to avoid merge
conflicts.

For more info on the IPC implementation and how to send/receive
messages, documentation can be found at
https://github.com/mihirlad55/dwm-ipc
2023-08-04 21:33:07 +02:00

62 lines
1.3 KiB
C

#ifndef IPC_CLIENT_H_
#define IPC_CLIENT_H_
#include <stdio.h>
#include <stdlib.h>
#include <sys/epoll.h>
typedef struct IPCClient IPCClient;
/**
* This structure contains the details of an IPC Client and pointers for a
* linked list
*/
struct IPCClient {
int fd;
int subscriptions;
char *buffer;
uint32_t buffer_size;
struct epoll_event event;
IPCClient *next;
IPCClient *prev;
};
typedef IPCClient *IPCClientList;
/**
* Allocate memory for new IPCClient with the specified file descriptor and
* initialize struct.
*
* @param fd File descriptor of IPC client
*
* @return Address to allocated IPCClient struct
*/
IPCClient *ipc_client_new(int fd);
/**
* Add an IPC Client to the specified list
*
* @param list Address of the list to add the client to
* @param nc Address of the IPCClient
*/
void ipc_list_add_client(IPCClientList *list, IPCClient *nc);
/**
* Remove an IPCClient from the specified list
*
* @param list Address of the list to remove the client from
* @param c Address of the IPCClient
*/
void ipc_list_remove_client(IPCClientList *list, IPCClient *c);
/**
* Get an IPCClient from the specified IPCClient list
*
* @param list List to remove the client from
* @param fd File descriptor of the IPCClient
*/
IPCClient *ipc_list_get_client(IPCClientList list, int fd);
#endif // IPC_CLIENT_H_