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