waybar/include/modules/hyprland/backend.hpp

29 lines
647 B
C++
Raw Normal View History

2022-07-01 12:46:28 +02:00
#pragma once
#include <deque>
#include <functional>
#include <memory>
#include <mutex>
#include <string>
2022-07-01 12:46:28 +02:00
#include <thread>
namespace waybar::modules::hyprland {
class IPC {
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);
private:
void startIPC();
void parseIPC(const std::string&);
2022-07-01 12:46:28 +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;
}; // namespace waybar::modules::hyprland