1 #pragma once
2 
3 #include "common.hpp"
4 #include "settings.hpp"
5 #include "utils/concurrency.hpp"
6 
7 POLYBAR_NS
8 
9 class file_descriptor;
10 class logger;
11 class signal_emitter;
12 
13 /**
14  * Message types
15  */
16 static constexpr const char* ipc_command_prefix{"cmd:"};
17 static constexpr const char* ipc_hook_prefix{"hook:"};
18 static constexpr const char* ipc_action_prefix{"action:"};
19 
20 /**
21  * Component used for inter-process communication.
22  *
23  * A unique messaging channel will be setup for each
24  * running process which will allow messages and
25  * events to be sent to the process externally.
26  */
27 class ipc {
28  public:
29   using make_type = unique_ptr<ipc>;
30   static make_type make();
31 
32   explicit ipc(signal_emitter& emitter, const logger& logger);
33   ~ipc();
34 
35   void receive_message();
36   int get_file_descriptor() const;
37 
38  private:
39   signal_emitter& m_sig;
40   const logger& m_log;
41 
42   string m_path{};
43   unique_ptr<file_descriptor> m_fd;
44 };
45 
46 POLYBAR_NS_END
47