diff options
Diffstat (limited to 'src/debug/HyprCtl.hpp')
| -rw-r--r-- | src/debug/HyprCtl.hpp | 40 |
1 files changed, 25 insertions, 15 deletions
diff --git a/src/debug/HyprCtl.hpp b/src/debug/HyprCtl.hpp index 00cf7c5b..1bef65a0 100644 --- a/src/debug/HyprCtl.hpp +++ b/src/debug/HyprCtl.hpp @@ -3,24 +3,34 @@ #include "../Compositor.hpp" #include <fstream> #include "../helpers/MiscFunctions.hpp" +#include <functional> -namespace HyprCtl { - void startHyprCtlSocket(); - std::string makeDynamicCall(const std::string& input); - - // very simple thread-safe request method - inline bool requestMade = false; - inline bool requestReady = false; - inline std::string request = ""; - - inline std::ifstream requestStream; - - inline wl_event_source* hyprCtlTickSource = nullptr; - - inline int iSocketFD = -1; +class CHyprCtl { + public: + CHyprCtl(); enum eHyprCtlOutputFormat { FORMAT_NORMAL = 0, FORMAT_JSON }; -};
\ No newline at end of file + + 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;
\ No newline at end of file |
