2016-11-14 08:21:18 +00:00
|
|
|
#pragma once
|
|
|
|
|
2016-11-20 22:04:31 +00:00
|
|
|
#include "modules/meta/static_module.hpp"
|
2016-11-14 08:21:18 +00:00
|
|
|
#include "utils/command.hpp"
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS
|
2016-11-14 08:21:18 +00:00
|
|
|
|
|
|
|
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 static_module<ipc_module> {
|
|
|
|
public:
|
2016-12-21 07:00:09 +00:00
|
|
|
/**
|
|
|
|
* 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);
|
2016-11-14 08:21:18 +00:00
|
|
|
|
2017-01-09 22:06:39 +00:00
|
|
|
void start();
|
2016-12-23 14:54:06 +00:00
|
|
|
void update() {}
|
2016-11-14 08:21:18 +00:00
|
|
|
string get_output();
|
2016-11-25 12:55:15 +00:00
|
|
|
bool build(builder* builder, const string& tag) const;
|
2016-12-26 09:36:14 +00:00
|
|
|
void on_message(const string& message);
|
2016-11-14 08:21:18 +00:00
|
|
|
|
2020-05-15 17:59:08 +00:00
|
|
|
static constexpr auto TYPE = "custom/ipc";
|
|
|
|
|
2016-11-14 08:21:18 +00:00
|
|
|
private:
|
2017-01-13 23:27:29 +00:00
|
|
|
static constexpr const char* TAG_OUTPUT{"<output>"};
|
2016-11-14 08:21:18 +00:00
|
|
|
vector<unique_ptr<hook>> m_hooks;
|
|
|
|
map<mousebtn, string> m_actions;
|
2017-01-13 23:27:29 +00:00
|
|
|
string m_output;
|
|
|
|
size_t m_initial;
|
2016-11-14 08:21:18 +00:00
|
|
|
};
|
2020-05-15 17:59:08 +00:00
|
|
|
} // namespace modules
|
2016-11-14 08:21:18 +00:00
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|