2016-11-13 13:05:30 -05:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common.hpp"
|
2017-01-10 21:07:28 -05:00
|
|
|
#include "settings.hpp"
|
2016-11-20 17:04:31 -05:00
|
|
|
#include "utils/concurrency.hpp"
|
2016-11-13 13:05:30 -05:00
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS
|
2016-11-13 13:05:30 -05:00
|
|
|
|
2017-01-10 21:07:28 -05:00
|
|
|
class file_descriptor;
|
|
|
|
class logger;
|
|
|
|
class signal_emitter;
|
|
|
|
|
2016-11-14 03:21:18 -05:00
|
|
|
/**
|
|
|
|
* Message types
|
|
|
|
*/
|
2019-10-28 04:57:02 -04:00
|
|
|
static constexpr const char* ipc_command_prefix{"cmd:"};
|
|
|
|
static constexpr const char* ipc_hook_prefix{"hook:"};
|
|
|
|
static constexpr const char* ipc_action_prefix{"action:"};
|
2016-11-14 03:21:18 -05:00
|
|
|
|
2016-11-13 13:05:30 -05: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 03:40:46 -05:00
|
|
|
using make_type = unique_ptr<ipc>;
|
|
|
|
static make_type make();
|
2016-12-09 03:02:47 -05:00
|
|
|
|
2016-12-19 23:05:43 -05:00
|
|
|
explicit ipc(signal_emitter& emitter, const logger& logger);
|
2016-11-13 13:05:30 -05:00
|
|
|
~ipc();
|
|
|
|
|
2016-12-19 23:05:43 -05:00
|
|
|
void receive_message();
|
|
|
|
int get_file_descriptor() const;
|
2016-11-13 13:05:30 -05:00
|
|
|
|
|
|
|
private:
|
2016-12-05 14:41:00 -05:00
|
|
|
signal_emitter& m_sig;
|
2016-11-13 13:05:30 -05:00
|
|
|
const logger& m_log;
|
2016-12-19 23:05:43 -05:00
|
|
|
|
|
|
|
string m_path{};
|
2017-05-23 15:32:34 -04:00
|
|
|
unique_ptr<file_descriptor> m_fd;
|
2016-11-13 13:05:30 -05:00
|
|
|
};
|
|
|
|
|
2016-11-19 00:22:44 -05:00
|
|
|
POLYBAR_NS_END
|