2022-07-01 10:46:28 +00:00
|
|
|
#pragma once
|
|
|
|
#include <deque>
|
|
|
|
#include <functional>
|
2021-05-27 13:40:54 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2022-07-01 10:46:28 +00:00
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
namespace waybar::modules::hyprland {
|
|
|
|
class IPC {
|
2021-05-27 13:40:54 +00:00
|
|
|
public:
|
2022-07-01 10:46:28 +00:00
|
|
|
IPC() { startIPC(); }
|
|
|
|
|
|
|
|
void registerForIPC(const std::string&, std::function<void(const std::string&)>);
|
|
|
|
|
|
|
|
std::string getSocket1Reply(const std::string& rq);
|
|
|
|
|
2021-05-27 13:40:54 +00:00
|
|
|
private:
|
|
|
|
void startIPC();
|
|
|
|
void parseIPC(const std::string&);
|
2022-07-01 10:46:28 +00:00
|
|
|
|
2021-05-27 13:40:54 +00:00
|
|
|
std::mutex callbackMutex;
|
|
|
|
std::deque<std::pair<std::string, std::function<void(const std::string&)>>> callbacks;
|
2022-07-01 10:46:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<IPC> gIPC;
|
|
|
|
inline bool modulesReady = false;
|
2021-05-27 13:40:54 +00:00
|
|
|
}; // namespace waybar::modules::hyprland
|