1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-11-11 13:50:56 -05:00
polybar/include/modules/ipc.hpp

52 lines
1.2 KiB
C++
Raw Normal View History

#pragma once
2016-11-20 17:04:31 -05:00
#include "modules/meta/static_module.hpp"
#include "utils/command.hpp"
2016-11-19 00:22:44 -05:00
POLYBAR_NS
namespace modules {
/**
* Module that allow users to configure hooks on
* received ipc messages. The hook will execute the defined
* shell script and the resulting output will be used
* as the module content.
*/
class ipc_module : public module<ipc_module> {
public:
/**
* Hook structure that will be fired
* when receiving a message with specified id
*/
struct hook {
string payload;
string command;
};
public:
explicit ipc_module(const bar_settings&, string);
void start() override;
2016-12-23 09:54:06 -05:00
void update() {}
string get_output();
2016-11-25 07:55:15 -05:00
bool build(builder* builder, const string& tag) const;
2016-12-26 04:36:14 -05:00
void on_message(const string& message);
static constexpr auto TYPE = "custom/ipc";
static constexpr auto EVENT_SEND = "send";
protected:
void action_send(const string& data);
private:
2017-01-13 18:27:29 -05:00
static constexpr const char* TAG_OUTPUT{"<output>"};
vector<unique_ptr<hook>> m_hooks;
map<mousebtn, string> m_actions;
2017-01-13 18:27:29 -05:00
string m_output;
size_t m_initial;
};
} // namespace modules
2016-11-19 00:22:44 -05:00
POLYBAR_NS_END