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
|
|
|
|
|
|
|
struct ipc_hook; // fwd
|
|
|
|
|
|
|
|
namespace modules {
|
|
|
|
/**
|
|
|
|
* Hook structure that will be fired
|
|
|
|
* when receiving a message with specified id
|
|
|
|
*/
|
|
|
|
struct hook {
|
|
|
|
string payload;
|
|
|
|
string command;
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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:
|
|
|
|
using static_module::static_module;
|
|
|
|
|
|
|
|
void setup();
|
|
|
|
string get_output();
|
|
|
|
bool build(builder* builder, string tag) const;
|
|
|
|
void on_message(const ipc_hook& msg);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static constexpr auto TAG_OUTPUT = "<output>";
|
|
|
|
vector<unique_ptr<hook>> m_hooks;
|
|
|
|
string m_output;
|
|
|
|
|
|
|
|
map<mousebtn, string> m_actions;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2016-11-19 05:22:44 +00:00
|
|
|
POLYBAR_NS_END
|