2016-11-13 19:05:30 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
2017-01-11 03:07:28 +01:00
|
|
|
#include "settings.hpp"
|
2016-11-20 23:04:31 +01:00
|
|
|
#include "utils/concurrency.hpp"
|
2016-11-13 19:05:30 +01:00
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS
|
2016-11-13 19:05:30 +01:00
|
|
|
|
2017-01-11 03:07:28 +01:00
|
|
|
class file_descriptor;
|
|
|
|
class logger;
|
|
|
|
class signal_emitter;
|
|
|
|
|
2016-11-14 09:21:18 +01:00
|
|
|
/**
|
|
|
|
* Message types
|
|
|
|
*/
|
|
|
|
struct ipc_command {
|
2016-11-20 23:29:42 +01:00
|
|
|
static constexpr const char* prefix{"cmd:"};
|
2016-12-05 20:41:00 +01:00
|
|
|
char payload[EVENT_SIZE]{'\0'};
|
2016-11-14 09:21:18 +01:00
|
|
|
};
|
|
|
|
struct ipc_hook {
|
2016-11-20 23:29:42 +01:00
|
|
|
static constexpr const char* prefix{"hook:"};
|
2016-12-05 20:41:00 +01:00
|
|
|
char payload[EVENT_SIZE]{'\0'};
|
2016-11-14 09:21:18 +01:00
|
|
|
};
|
2016-11-18 18:37:52 +01:00
|
|
|
struct ipc_action {
|
2016-11-20 23:29:42 +01:00
|
|
|
static constexpr const char* prefix{"action:"};
|
2016-12-05 20:41:00 +01:00
|
|
|
char payload[EVENT_SIZE]{'\0'};
|
2016-11-18 18:37:52 +01:00
|
|
|
};
|
2016-11-14 09:21:18 +01:00
|
|
|
|
2016-11-13 19:05:30 +01:00
|
|
|
/**
|
|
|
|
* Component used for inter-process communication.
|
|
|
|
*
|
|
|
|
* A unique messaging channel will be setup for each
|
|
|
|
* running process which will allow messages and
|
|
|
|
* events to be sent to the process externally.
|
|
|
|
*/
|
|
|
|
class ipc {
|
|
|
|
public:
|
2016-12-09 09:40:46 +01:00
|
|
|
using make_type = unique_ptr<ipc>;
|
|
|
|
static make_type make();
|
2016-12-09 09:02:47 +01:00
|
|
|
|
2016-12-20 05:05:43 +01:00
|
|
|
explicit ipc(signal_emitter& emitter, const logger& logger);
|
2016-11-13 19:05:30 +01:00
|
|
|
~ipc();
|
|
|
|
|
2016-12-20 05:05:43 +01:00
|
|
|
void receive_message();
|
|
|
|
int get_file_descriptor() const;
|
2016-11-13 19:05:30 +01:00
|
|
|
|
|
|
|
private:
|
2016-12-05 20:41:00 +01:00
|
|
|
signal_emitter& m_sig;
|
2016-11-13 19:05:30 +01:00
|
|
|
const logger& m_log;
|
2016-12-20 05:05:43 +01:00
|
|
|
|
|
|
|
string m_path{};
|
2016-12-23 01:07:00 +01:00
|
|
|
unique_ptr<file_descriptor> m_fd{};
|
2016-11-13 19:05:30 +01:00
|
|
|
};
|
|
|
|
|
2016-11-19 06:22:44 +01:00
|
|
|
POLYBAR_NS_END
|