mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-08-11 02:01:53 -07:00
Plugin System (#1590)
--------- Co-authored-by: Mihai Fufezan <fufexan@protonmail.com>
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user