2022-03-20 16:51:14 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../Compositor.hpp"
|
|
|
|
#include <fstream>
|
2022-04-04 19:44:25 +02:00
|
|
|
#include "../helpers/MiscFunctions.hpp"
|
2024-02-05 02:43:45 +01:00
|
|
|
#include <functional>
|
2022-03-20 16:51:14 +01:00
|
|
|
|
2024-02-05 02:43:45 +01:00
|
|
|
class CHyprCtl {
|
|
|
|
public:
|
|
|
|
CHyprCtl();
|
2022-08-28 11:19:08 +02:00
|
|
|
|
2023-12-06 23:54:56 +01:00
|
|
|
enum eHyprCtlOutputFormat {
|
2022-07-12 22:59:36 +02:00
|
|
|
FORMAT_NORMAL = 0,
|
|
|
|
FORMAT_JSON
|
|
|
|
};
|
2024-02-05 02:43:45 +01:00
|
|
|
|
|
|
|
struct SCommand {
|
|
|
|
std::string name = "";
|
|
|
|
bool exact = true;
|
|
|
|
std::function<std::string(eHyprCtlOutputFormat, std::string)> fn;
|
|
|
|
};
|
|
|
|
|
|
|
|
std::string makeDynamicCall(const std::string& input);
|
|
|
|
std::shared_ptr<SCommand> registerCommand(SCommand cmd);
|
|
|
|
void unregisterCommand(const std::shared_ptr<SCommand>& cmd);
|
|
|
|
std::string getReply(std::string);
|
|
|
|
|
|
|
|
int m_iSocketFD = -1;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void startHyprCtlSocket();
|
|
|
|
|
|
|
|
std::vector<std::shared_ptr<SCommand>> m_vCommands;
|
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<CHyprCtl> g_pHyprCtl;
|