summaryrefslogtreecommitdiff
path: root/src/plugins/PluginAPI.cpp
diff options
context:
space:
mode:
authorVaxry <vaxry@vaxry.net>2024-02-05 01:56:38 +0000
committerVaxry <vaxry@vaxry.net>2024-02-05 01:57:29 +0000
commit60bda7ee3d0a77d19277540cce53ecbddeabd716 (patch)
tree813a2342a3e56c174b5bee91bf274bc6081ef56c /src/plugins/PluginAPI.cpp
parent939696f97e2dcfa9ed6b91aa7ddf608c454d49e5 (diff)
pluginapi: allow registering hyprctl commands
closes #4616
Diffstat (limited to 'src/plugins/PluginAPI.cpp')
-rw-r--r--src/plugins/PluginAPI.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/plugins/PluginAPI.cpp b/src/plugins/PluginAPI.cpp
index e6fe6138..b6a353ea 100644
--- a/src/plugins/PluginAPI.cpp
+++ b/src/plugins/PluginAPI.cpp
@@ -362,4 +362,28 @@ APICALL SVersionInfo HyprlandAPI::getHyprlandVersion(HANDLE handle) {
return {};
return {GIT_COMMIT_HASH, GIT_TAG, GIT_DIRTY != std::string(""), GIT_BRANCH, GIT_COMMIT_MESSAGE};
+}
+
+APICALL std::shared_ptr<SHyprCtlCommand> HyprlandAPI::registerHyprCtlCommand(HANDLE handle, SHyprCtlCommand cmd) {
+ auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
+
+ if (!PLUGIN)
+ return nullptr;
+
+ auto PTR = g_pHyprCtl->registerCommand(cmd);
+ PLUGIN->registeredHyprctlCommands.push_back(PTR);
+ return PTR;
+}
+
+APICALL bool HyprlandAPI::unregisterHyprCtlCommand(HANDLE handle, std::shared_ptr<SHyprCtlCommand> cmd) {
+
+ auto* const PLUGIN = g_pPluginSystem->getPluginByHandle(handle);
+
+ if (!PLUGIN)
+ return false;
+
+ std::erase(PLUGIN->registeredHyprctlCommands, cmd);
+ g_pHyprCtl->unregisterCommand(cmd);
+
+ return true;
} \ No newline at end of file