1 #pragma once 2 3 #include "modules/meta/static_module.hpp" 4 #include "utils/command.hpp" 5 6 POLYBAR_NS 7 8 namespace modules { 9 /** 10 * Module that allow users to configure hooks on 11 * received ipc messages. The hook will execute the defined 12 * shell script and the resulting output will be used 13 * as the module content. 14 */ 15 class ipc_module : public static_module<ipc_module> { 16 public: 17 /** 18 * Hook structure that will be fired 19 * when receiving a message with specified id 20 */ 21 struct hook { 22 string payload; 23 string command; 24 }; 25 26 public: 27 explicit ipc_module(const bar_settings&, string); 28 29 void start(); update()30 void update() {} 31 string get_output(); 32 bool build(builder* builder, const string& tag) const; 33 void on_message(const string& message); 34 35 static constexpr auto TYPE = "custom/ipc"; 36 37 private: 38 static constexpr const char* TAG_OUTPUT{"<output>"}; 39 vector<unique_ptr<hook>> m_hooks; 40 map<mousebtn, string> m_actions; 41 string m_output; 42 size_t m_initial; 43 }; 44 } // namespace modules 45 46 POLYBAR_NS_END 47