1
0
Fork 0
mirror of https://github.com/polybar/polybar.git synced 2024-10-27 05:23:39 -04:00
polybar/include/modules/ipc.hpp
Michael Carlberg 7a26254844 feat(ipc): Initial exec of configured hook
Adds a new config parameter `initial = N` that will
make the hook at defined index N execute on start.
2017-01-09 23:06:41 +01:00

46 lines
1 KiB
C++

#pragma once
#include "modules/meta/static_module.hpp"
#include "utils/command.hpp"
POLYBAR_NS
struct ipc_hook; // fwd
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:
/**
* 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();
void update() {}
string get_output();
bool build(builder* builder, const string& tag) const;
void on_message(const string& message);
private:
static constexpr auto TAG_OUTPUT = "<output>";
vector<unique_ptr<hook>> m_hooks;
string m_output;
size_t m_initial{0_z};
map<mousebtn, string> m_actions;
};
}
POLYBAR_NS_END