summaryrefslogtreecommitdiff
path: root/src/debug/HyprCtl.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2023-02-27 12:32:38 +0000
committerGitHub <noreply@github.com>2023-02-27 12:32:38 +0000
commit8b81f41e52b55835aaaa7e4962af23a00188cbdc (patch)
treebca65923843ea931c0e0222f29d4e2901cfa8637 /src/debug/HyprCtl.cpp
parent74a10f26a469de54968e584525f6507928f615f0 (diff)
Plugin System (#1590)
--------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
Diffstat (limited to 'src/debug/HyprCtl.cpp')
-rw-r--r--src/debug/HyprCtl.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/debug/HyprCtl.cpp b/src/debug/HyprCtl.cpp
index 91af3938..f6ed285b 100644
--- a/src/debug/HyprCtl.cpp
+++ b/src/debug/HyprCtl.cpp
@@ -1087,6 +1087,50 @@ std::string dispatchOutput(std::string request) {
return "ok";
}
+std::string dispatchPlugin(std::string request) {
+ CVarList vars(request, 0, ' ');
+
+ if (vars.size() < 2)
+ return "not enough args";
+
+ const auto OPERATION = vars[1];
+ const auto PATH = vars[2];
+
+ if (OPERATION == "load") {
+ if (vars.size() < 3)
+ return "not enough args";
+
+ const auto PLUGIN = g_pPluginSystem->loadPlugin(PATH);
+
+ if (!PLUGIN)
+ return "error in loading plugin";
+ } else if (OPERATION == "unload") {
+ if (vars.size() < 3)
+ return "not enough args";
+
+ const auto PLUGIN = g_pPluginSystem->getPluginByPath(PATH);
+
+ if (!PLUGIN)
+ return "plugin not loaded";
+
+ g_pPluginSystem->unloadPlugin(PLUGIN);
+ } else if (OPERATION == "list") {
+ const auto PLUGINS = g_pPluginSystem->getAllPlugins();
+
+ std::string list = "";
+ for (auto& p : PLUGINS) {
+ list += getFormat("\nPlugin %s by %s:\n\tHandle: %lx\n\tVersion: %s\n\tDescription: %s\n", p->name.c_str(), p->author.c_str(), p->m_pHandle, p->version.c_str(),
+ p->description.c_str());
+ }
+
+ return list;
+ } else {
+ return "unknown opt";
+ }
+
+ return "ok";
+}
+
std::string getReply(std::string request) {
auto format = HyprCtl::FORMAT_NORMAL;
@@ -1134,6 +1178,8 @@ std::string getReply(std::string request) {
return bindsRequest(format);
else if (request == "animations")
return animationsRequest(format);
+ else if (request.find("plugin") == 0)
+ return dispatchPlugin(request);
else if (request.find("setprop") == 0)
return dispatchSetProp(request);
else if (request.find("seterror") == 0)
@@ -1156,6 +1202,10 @@ std::string getReply(std::string request) {
return "unknown request";
}
+std::string HyprCtl::makeDynamicCall(const std::string& input) {
+ return getReply(input);
+}
+
int hyprCtlFDTick(int fd, uint32_t mask, void* data) {
if (mask & WL_EVENT_ERROR || mask & WL_EVENT_HANGUP)
return 0;